@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,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-Fjyk5jYL.js');
4
- var index_browser = require('./index.browser-DjEZSiqI.js');
3
+ var index_browser = require('./index.browser-vuTr40so.js');
4
+ var index = require('./index-B2WGCssJ.js');
5
5
  require('axios');
6
6
  require('@solana/web3.js');
7
7
  require('@coral-xyz/anchor');
@@ -22,6 +22,15 @@ const SolanaSignMessage = 'solana:signMessage';
22
22
  /** Name of the feature. */
23
23
  const SolanaSignTransaction = 'solana:signTransaction';
24
24
 
25
+ /** Name of the feature. */
26
+ const StandardConnect = 'standard:connect';
27
+
28
+ /** Name of the feature. */
29
+ const StandardDisconnect = 'standard:disconnect';
30
+
31
+ /** Name of the feature. */
32
+ const StandardEvents = 'standard:events';
33
+
25
34
  var browser = {};
26
35
 
27
36
  var canPromise;
@@ -3094,200 +3103,239 @@ function requireBrowser () {
3094
3103
  var browserExports = requireBrowser();
3095
3104
  var QRCode = /*@__PURE__*/index.getDefaultExportFromCjs(browserExports);
3096
3105
 
3097
- /** Name of the feature. */
3098
- const StandardConnect = 'standard:connect';
3099
-
3100
- /** Name of the feature. */
3101
- const StandardDisconnect = 'standard:disconnect';
3102
-
3103
- /** Name of the feature. */
3104
- const StandardEvents = 'standard:events';
3105
-
3106
- var src;
3107
- var hasRequiredSrc;
3108
-
3109
- function requireSrc () {
3110
- if (hasRequiredSrc) return src;
3111
- hasRequiredSrc = 1;
3112
- // base-x encoding / decoding
3113
- // Copyright (c) 2018 base-x contributors
3114
- // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
3115
- // Distributed under the MIT software license, see the accompanying
3116
- // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
3117
- function base (ALPHABET) {
3118
- if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
3119
- var BASE_MAP = new Uint8Array(256);
3120
- for (var j = 0; j < BASE_MAP.length; j++) {
3121
- BASE_MAP[j] = 255;
3122
- }
3123
- for (var i = 0; i < ALPHABET.length; i++) {
3124
- var x = ALPHABET.charAt(i);
3125
- var xc = x.charCodeAt(0);
3126
- if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
3127
- BASE_MAP[xc] = i;
3128
- }
3129
- var BASE = ALPHABET.length;
3130
- var LEADER = ALPHABET.charAt(0);
3131
- var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
3132
- var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
3133
- function encode (source) {
3134
- if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
3135
- source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
3136
- } else if (Array.isArray(source)) {
3137
- source = Uint8Array.from(source);
3138
- }
3139
- if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
3140
- if (source.length === 0) { return '' }
3141
- // Skip & count leading zeroes.
3142
- var zeroes = 0;
3143
- var length = 0;
3144
- var pbegin = 0;
3145
- var pend = source.length;
3146
- while (pbegin !== pend && source[pbegin] === 0) {
3147
- pbegin++;
3148
- zeroes++;
3149
- }
3150
- // Allocate enough space in big-endian base58 representation.
3151
- var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
3152
- var b58 = new Uint8Array(size);
3153
- // Process the bytes.
3154
- while (pbegin !== pend) {
3155
- var carry = source[pbegin];
3156
- // Apply "b58 = b58 * 256 + ch".
3157
- var i = 0;
3158
- for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
3159
- carry += (256 * b58[it1]) >>> 0;
3160
- b58[it1] = (carry % BASE) >>> 0;
3161
- carry = (carry / BASE) >>> 0;
3162
- }
3163
- if (carry !== 0) { throw new Error('Non-zero carry') }
3164
- length = i;
3165
- pbegin++;
3166
- }
3167
- // Skip leading zeroes in base58 result.
3168
- var it2 = size - length;
3169
- while (it2 !== size && b58[it2] === 0) {
3170
- it2++;
3171
- }
3172
- // Translate the result into a string.
3173
- var str = LEADER.repeat(zeroes);
3174
- for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
3175
- return str
3176
- }
3177
- function decodeUnsafe (source) {
3178
- if (typeof source !== 'string') { throw new TypeError('Expected String') }
3179
- if (source.length === 0) { return new Uint8Array() }
3180
- var psz = 0;
3181
- // Skip and count leading '1's.
3182
- var zeroes = 0;
3183
- var length = 0;
3184
- while (source[psz] === LEADER) {
3185
- zeroes++;
3186
- psz++;
3187
- }
3188
- // Allocate enough space in big-endian base256 representation.
3189
- var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
3190
- var b256 = new Uint8Array(size);
3191
- // Process the characters.
3192
- while (source[psz]) {
3193
- // Find code of next character
3194
- var charCode = source.charCodeAt(psz);
3195
- // Base map can not be indexed using char code
3196
- if (charCode > 255) { return }
3197
- // Decode character
3198
- var carry = BASE_MAP[charCode];
3199
- // Invalid character
3200
- if (carry === 255) { return }
3201
- var i = 0;
3202
- for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
3203
- carry += (BASE * b256[it3]) >>> 0;
3204
- b256[it3] = (carry % 256) >>> 0;
3205
- carry = (carry / 256) >>> 0;
3206
- }
3207
- if (carry !== 0) { throw new Error('Non-zero carry') }
3208
- length = i;
3209
- psz++;
3210
- }
3211
- // Skip leading zeroes in b256.
3212
- var it4 = size - length;
3213
- while (it4 !== size && b256[it4] === 0) {
3214
- it4++;
3215
- }
3216
- var vch = new Uint8Array(zeroes + (size - it4));
3217
- var j = zeroes;
3218
- while (it4 !== size) {
3219
- vch[j++] = b256[it4++];
3220
- }
3221
- return vch
3222
- }
3223
- function decode (string) {
3224
- var buffer = decodeUnsafe(string);
3225
- if (buffer) { return buffer }
3226
- throw new Error('Non-base' + BASE + ' character')
3227
- }
3228
- return {
3229
- encode: encode,
3230
- decodeUnsafe: decodeUnsafe,
3231
- decode: decode
3232
- }
3233
- }
3234
- src = base;
3235
- return src;
3106
+ var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3107
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3108
+ 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");
3109
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3110
+ };
3111
+ var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3112
+ if (kind === "m") throw new TypeError("Private method is not writable");
3113
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3114
+ 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");
3115
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
3116
+ };
3117
+ var _RegisterWalletEvent_detail;
3118
+ /**
3119
+ * Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
3120
+ *
3121
+ * This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
3122
+ * ready to be registered.
3123
+ *
3124
+ * This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
3125
+ * the app that the app is ready to register the Wallet.
3126
+ *
3127
+ * This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
3128
+ * as the app is ready whether the Wallet loads before or after the app.
3129
+ *
3130
+ * @param wallet Wallet to register.
3131
+ *
3132
+ * @group Wallet
3133
+ */
3134
+ function registerWallet(wallet) {
3135
+ const callback = ({ register }) => register(wallet);
3136
+ try {
3137
+ window.dispatchEvent(new RegisterWalletEvent(callback));
3138
+ }
3139
+ catch (error) {
3140
+ console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
3141
+ }
3142
+ try {
3143
+ window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
3144
+ }
3145
+ catch (error) {
3146
+ console.error('wallet-standard:app-ready event listener could not be added\n', error);
3147
+ }
3236
3148
  }
3149
+ class RegisterWalletEvent extends Event {
3150
+ get detail() {
3151
+ return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
3152
+ }
3153
+ get type() {
3154
+ return 'wallet-standard:register-wallet';
3155
+ }
3156
+ constructor(callback) {
3157
+ super('wallet-standard:register-wallet', {
3158
+ bubbles: false,
3159
+ cancelable: false,
3160
+ composed: false,
3161
+ });
3162
+ _RegisterWalletEvent_detail.set(this, void 0);
3163
+ __classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
3164
+ }
3165
+ /** @deprecated */
3166
+ preventDefault() {
3167
+ throw new Error('preventDefault cannot be called');
3168
+ }
3169
+ /** @deprecated */
3170
+ stopImmediatePropagation() {
3171
+ throw new Error('stopImmediatePropagation cannot be called');
3172
+ }
3173
+ /** @deprecated */
3174
+ stopPropagation() {
3175
+ throw new Error('stopPropagation cannot be called');
3176
+ }
3177
+ }
3178
+ _RegisterWalletEvent_detail = new WeakMap();
3237
3179
 
3238
- var bs58;
3239
- var hasRequiredBs58;
3240
-
3241
- function requireBs58 () {
3242
- if (hasRequiredBs58) return bs58;
3243
- hasRequiredBs58 = 1;
3244
- const basex = requireSrc();
3245
- const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
3246
-
3247
- bs58 = basex(ALPHABET);
3248
- return bs58;
3180
+ //#region src/base64Utils.ts
3181
+ function fromUint8Array(byteArray) {
3182
+ return window.btoa(String.fromCharCode.call(null, ...byteArray));
3183
+ }
3184
+ function toUint8Array(base64EncodedByteArray) {
3185
+ return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
3186
+ }
3187
+ //#endregion
3188
+ //#region src/embedded-modal/loadingSpinner.ts
3189
+ const modalHtml$1 = `
3190
+ <div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
3191
+ <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
3192
+ <div class="mobile-wallet-adapter-embedded-loading-container">
3193
+ <div class="mobile-wallet-adapter-embedded-loading-animation"></div>
3194
+ </div>
3195
+ </div>
3196
+ `;
3197
+ const css$6 = `
3198
+ .mobile-wallet-adapter-embedded-loading-indicator {
3199
+ display: flex; /* Use flexbox to center content */
3200
+ justify-content: center; /* Center horizontally */
3201
+ align-items: start; /* Center vertically */
3202
+ position: fixed; /* Stay in place */
3203
+ z-index: 1; /* Sit on top */
3204
+ left: 0;
3205
+ top: 0;
3206
+ width: 100%; /* Full width */
3207
+ height: 100%; /* Full height */
3208
+ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
3209
+ overflow-y: auto; /* enable scrolling */
3249
3210
  }
3250
3211
 
3251
- var bs58Exports = requireBs58();
3252
- var base58 = /*@__PURE__*/index.getDefaultExportFromCjs(bs58Exports);
3212
+ .mobile-wallet-adapter-embedded-loading-container {
3213
+ display: flex;
3214
+ margin: auto;
3215
+ }
3253
3216
 
3254
- /******************************************************************************
3255
- Copyright (c) Microsoft Corporation.
3256
-
3257
- Permission to use, copy, modify, and/or distribute this software for any
3258
- purpose with or without fee is hereby granted.
3259
-
3260
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3261
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3262
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3263
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3264
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3265
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3266
- PERFORMANCE OF THIS SOFTWARE.
3267
- ***************************************************************************** */
3268
-
3269
- function __awaiter(thisArg, _arguments, P, generator) {
3270
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3271
- return new (P || (P = Promise))(function (resolve, reject) {
3272
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3273
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3274
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3275
- step((generator = generator.apply(thisArg, [])).next());
3276
- });
3277
- }
3278
-
3279
- function __classPrivateFieldGet$1(receiver, state, kind, f) {
3280
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3281
- 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");
3282
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3283
- }
3284
-
3285
- function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
3286
- 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");
3287
- return (state.set(receiver, value)), value;
3217
+ .mobile-wallet-adapter-embedded-loading-animation {
3218
+ position: relative;
3219
+ left: -9999px;
3220
+ width: 10px;
3221
+ height: 10px;
3222
+ border-radius: 5px;
3223
+ background-color: var(--spinner-color);
3224
+ color: var(--spinner-color);
3225
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3226
+ 9999px 0 0 0 var(--spinner-color),
3227
+ 10014px 0 0 0 var(--spinner-color);
3228
+ animation: dot-typing 1.5s infinite linear;
3288
3229
  }
3289
3230
 
3290
- var _EmbeddedModal_instances, _EmbeddedModal_root, _EmbeddedModal_eventListeners, _EmbeddedModal_listenersAttached, _EmbeddedModal_injectHTML, _EmbeddedModal_attachEventListeners, _EmbeddedModal_removeEventListeners, _EmbeddedModal_handleKeyDown;
3231
+ @keyframes dot-typing {
3232
+ 0% {
3233
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3234
+ 9999px 0 0 0 var(--spinner-color),
3235
+ 10014px 0 0 0 var(--spinner-color);
3236
+ }
3237
+ 16.667% {
3238
+ box-shadow: 9984px -10px 0 0 var(--spinner-color),
3239
+ 9999px 0 0 0 var(--spinner-color),
3240
+ 10014px 0 0 0 var(--spinner-color);
3241
+ }
3242
+ 33.333% {
3243
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3244
+ 9999px 0 0 0 var(--spinner-color),
3245
+ 10014px 0 0 0 var(--spinner-color);
3246
+ }
3247
+ 50% {
3248
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3249
+ 9999px -10px 0 0 var(--spinner-color),
3250
+ 10014px 0 0 0 var(--spinner-color);
3251
+ }
3252
+ 66.667% {
3253
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3254
+ 9999px 0 0 0 var(--spinner-color),
3255
+ 10014px 0 0 0 var(--spinner-color);
3256
+ }
3257
+ 83.333% {
3258
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3259
+ 9999px 0 0 0 var(--spinner-color),
3260
+ 10014px -10px 0 0 var(--spinner-color);
3261
+ }
3262
+ 100% {
3263
+ box-shadow: 9984px 0 0 0 var(--spinner-color),
3264
+ 9999px 0 0 0 var(--spinner-color),
3265
+ 10014px 0 0 0 var(--spinner-color);
3266
+ }
3267
+ }
3268
+ `;
3269
+ var EmbeddedLoadingSpinner = class {
3270
+ #root = null;
3271
+ #eventListeners = {};
3272
+ #listenersAttached = false;
3273
+ dom = null;
3274
+ constructor() {
3275
+ this.init = this.init.bind(this);
3276
+ this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
3277
+ }
3278
+ async init() {
3279
+ console.log("Injecting modal");
3280
+ this.#injectHTML();
3281
+ }
3282
+ open = () => {
3283
+ console.debug("Modal open");
3284
+ this.#attachEventListeners();
3285
+ if (this.#root) this.#root.style.display = "flex";
3286
+ };
3287
+ close = (event = void 0) => {
3288
+ console.debug("Modal close");
3289
+ this.#removeEventListeners();
3290
+ if (this.#root) this.#root.style.display = "none";
3291
+ this.#eventListeners["close"]?.forEach((listener) => listener(event));
3292
+ };
3293
+ addEventListener(event, listener) {
3294
+ this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
3295
+ return () => this.removeEventListener(event, listener);
3296
+ }
3297
+ removeEventListener(event, listener) {
3298
+ this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
3299
+ }
3300
+ #injectHTML() {
3301
+ if (this.dom) return;
3302
+ this.#root = document.createElement("div");
3303
+ this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
3304
+ this.#root.innerHTML = modalHtml$1;
3305
+ this.#root.style.display = "none";
3306
+ const styles = document.createElement("style");
3307
+ styles.id = "mobile-wallet-adapter-embedded-modal-styles";
3308
+ styles.textContent = css$6;
3309
+ const host = document.createElement("div");
3310
+ this.dom = host.attachShadow({ mode: "closed" });
3311
+ host.style.setProperty("--spinner-color", "#FFFFFF");
3312
+ this.dom.appendChild(styles);
3313
+ this.dom.appendChild(this.#root);
3314
+ document.body.appendChild(host);
3315
+ }
3316
+ #attachEventListeners() {
3317
+ if (!this.#root || this.#listenersAttached) return;
3318
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
3319
+ this.close(event);
3320
+ }));
3321
+ window.addEventListener("load", this.close);
3322
+ document.addEventListener("keydown", this.#handleKeyDown);
3323
+ this.#listenersAttached = true;
3324
+ }
3325
+ #removeEventListeners() {
3326
+ if (!this.#listenersAttached) return;
3327
+ window.removeEventListener("load", this.close);
3328
+ document.removeEventListener("keydown", this.#handleKeyDown);
3329
+ if (!this.#root) return;
3330
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
3331
+ this.#listenersAttached = false;
3332
+ }
3333
+ #handleKeyDown = (event) => {
3334
+ if (event.key === "Escape") this.close(event);
3335
+ };
3336
+ };
3337
+ //#endregion
3338
+ //#region src/embedded-modal/modal.ts
3291
3339
  const modalHtml = `
3292
3340
  <div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
3293
3341
  <div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
@@ -3303,13 +3351,13 @@ const modalHtml = `
3303
3351
  </div>
3304
3352
  </div>
3305
3353
  `;
3306
- const css$2 = `
3354
+ const css$5 = `
3307
3355
  .mobile-wallet-adapter-embedded-modal-container {
3308
3356
  display: flex; /* Use flexbox to center content */
3309
3357
  justify-content: center; /* Center horizontally */
3310
3358
  align-items: center; /* Center vertically */
3311
3359
  position: fixed; /* Stay in place */
3312
- z-index: 1; /* Sit on top */
3360
+ z-index: 2147483647; /* Sit on top */
3313
3361
  left: 0;
3314
3362
  top: 0;
3315
3363
  width: 100%; /* Full width */
@@ -3365,134 +3413,100 @@ const fonts = `
3365
3413
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
3366
3414
  <link href="https://fonts.googleapis.com/css2?family=Inter+Tight:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
3367
3415
  `;
3368
- class EmbeddedModal {
3369
- constructor() {
3370
- _EmbeddedModal_instances.add(this);
3371
- _EmbeddedModal_root.set(this, null);
3372
- _EmbeddedModal_eventListeners.set(this, {});
3373
- _EmbeddedModal_listenersAttached.set(this, false);
3374
- this.dom = null;
3375
- this.open = () => {
3376
- console.debug('Modal open');
3377
- __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_attachEventListeners).call(this);
3378
- if (__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f")) {
3379
- __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'flex';
3380
- }
3381
- };
3382
- this.close = (event = undefined) => {
3383
- var _a;
3384
- console.debug('Modal close');
3385
- __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_removeEventListeners).call(this);
3386
- if (__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f")) {
3387
- __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'none';
3388
- }
3389
- (_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")['close']) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener(event));
3390
- };
3391
- _EmbeddedModal_handleKeyDown.set(this, (event) => {
3392
- if (event.key === 'Escape')
3393
- this.close(event);
3394
- });
3395
- // Bind methods to ensure `this` context is correct
3396
- this.init = this.init.bind(this);
3397
- __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.getElementById('mobile-wallet-adapter-embedded-root-ui'));
3398
- }
3399
- init() {
3400
- return __awaiter(this, void 0, void 0, function* () {
3401
- console.log('Injecting modal');
3402
- __classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_injectHTML).call(this);
3403
- });
3404
- }
3405
- addEventListener(event, listener) {
3406
- var _a;
3407
- ((_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]);
3408
- return () => this.removeEventListener(event, listener);
3409
- }
3410
- removeEventListener(event, listener) {
3411
- var _a;
3412
- __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);
3413
- }
3414
- }
3415
- _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() {
3416
- // Check if the HTML has already been injected
3417
- if (document.getElementById('mobile-wallet-adapter-embedded-root-ui')) {
3418
- if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"))
3419
- __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.getElementById('mobile-wallet-adapter-embedded-root-ui'));
3420
- return;
3421
- }
3422
- // Create a container for the modal
3423
- __classPrivateFieldSet$1(this, _EmbeddedModal_root, document.createElement('div'));
3424
- __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").id = 'mobile-wallet-adapter-embedded-root-ui';
3425
- __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").innerHTML = modalHtml;
3426
- __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'none';
3427
- // Add modal content
3428
- const content = __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelector('.mobile-wallet-adapter-embedded-modal-content');
3429
- if (content)
3430
- content.innerHTML = this.contentHtml;
3431
- // Apply styles
3432
- const styles = document.createElement('style');
3433
- styles.id = 'mobile-wallet-adapter-embedded-modal-styles';
3434
- styles.textContent = css$2 + this.contentStyles;
3435
- // Create a shadow DOM to encapsulate the modal
3436
- const host = document.createElement('div');
3437
- host.innerHTML = fonts;
3438
- this.dom = host.attachShadow({ mode: 'closed' });
3439
- this.dom.appendChild(styles);
3440
- this.dom.appendChild(__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"));
3441
- // Append the shadow DOM host to the body
3442
- document.body.appendChild(host);
3443
- }, _EmbeddedModal_attachEventListeners = function _EmbeddedModal_attachEventListeners() {
3444
- if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f") || __classPrivateFieldGet$1(this, _EmbeddedModal_listenersAttached, "f"))
3445
- return;
3446
- const closers = [...__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelectorAll('[data-modal-close]')];
3447
- closers.forEach(closer => closer === null || closer === void 0 ? void 0 : closer.addEventListener('click', this.close));
3448
- window.addEventListener('load', this.close);
3449
- document.addEventListener('keydown', __classPrivateFieldGet$1(this, _EmbeddedModal_handleKeyDown, "f"));
3450
- __classPrivateFieldSet$1(this, _EmbeddedModal_listenersAttached, true);
3451
- }, _EmbeddedModal_removeEventListeners = function _EmbeddedModal_removeEventListeners() {
3452
- if (!__classPrivateFieldGet$1(this, _EmbeddedModal_listenersAttached, "f"))
3453
- return;
3454
- window.removeEventListener('load', this.close);
3455
- document.removeEventListener('keydown', __classPrivateFieldGet$1(this, _EmbeddedModal_handleKeyDown, "f"));
3456
- if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"))
3457
- return;
3458
- const closers = [...__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelectorAll('[data-modal-close]')];
3459
- closers.forEach(closer => closer === null || closer === void 0 ? void 0 : closer.removeEventListener('click', this.close));
3460
- __classPrivateFieldSet$1(this, _EmbeddedModal_listenersAttached, false);
3416
+ var EmbeddedModal = class {
3417
+ #root = null;
3418
+ #eventListeners = {};
3419
+ #listenersAttached = false;
3420
+ dom = null;
3421
+ constructor() {
3422
+ this.init = this.init.bind(this);
3423
+ this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
3424
+ }
3425
+ async init() {
3426
+ console.log("Injecting modal");
3427
+ this.#injectHTML();
3428
+ }
3429
+ open = () => {
3430
+ console.debug("Modal open");
3431
+ this.#attachEventListeners();
3432
+ if (this.#root) this.#root.style.display = "flex";
3433
+ };
3434
+ close = (event = void 0) => {
3435
+ console.debug("Modal close");
3436
+ this.#removeEventListeners();
3437
+ if (this.#root) this.#root.style.display = "none";
3438
+ this.#eventListeners["close"]?.forEach((listener) => listener(event));
3439
+ };
3440
+ addEventListener(event, listener) {
3441
+ this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
3442
+ return () => this.removeEventListener(event, listener);
3443
+ }
3444
+ removeEventListener(event, listener) {
3445
+ this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
3446
+ }
3447
+ #injectHTML() {
3448
+ if (document.getElementById("mobile-wallet-adapter-embedded-root-ui")) {
3449
+ if (!this.#root) this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
3450
+ return;
3451
+ }
3452
+ this.#root = document.createElement("div");
3453
+ this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
3454
+ this.#root.innerHTML = modalHtml;
3455
+ this.#root.style.display = "none";
3456
+ const content = this.#root.querySelector(".mobile-wallet-adapter-embedded-modal-content");
3457
+ if (content) content.innerHTML = this.contentHtml;
3458
+ const styles = document.createElement("style");
3459
+ styles.id = "mobile-wallet-adapter-embedded-modal-styles";
3460
+ styles.textContent = css$5 + this.contentStyles;
3461
+ const host = document.createElement("div");
3462
+ host.innerHTML = fonts;
3463
+ this.dom = host.attachShadow({ mode: "closed" });
3464
+ this.dom.appendChild(styles);
3465
+ this.dom.appendChild(this.#root);
3466
+ document.body.appendChild(host);
3467
+ }
3468
+ #attachEventListeners() {
3469
+ if (!this.#root || this.#listenersAttached) return;
3470
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", this.close));
3471
+ window.addEventListener("load", this.close);
3472
+ document.addEventListener("keydown", this.#handleKeyDown);
3473
+ this.#listenersAttached = true;
3474
+ }
3475
+ #removeEventListeners() {
3476
+ if (!this.#listenersAttached) return;
3477
+ window.removeEventListener("load", this.close);
3478
+ document.removeEventListener("keydown", this.#handleKeyDown);
3479
+ if (!this.#root) return;
3480
+ [...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
3481
+ this.#listenersAttached = false;
3482
+ }
3483
+ #handleKeyDown = (event) => {
3484
+ if (event.key === "Escape") this.close(event);
3485
+ };
3486
+ };
3487
+ //#endregion
3488
+ //#region src/embedded-modal/remoteConnectionModal.ts
3489
+ var RemoteConnectionModal = class extends EmbeddedModal {
3490
+ contentStyles = css$4;
3491
+ contentHtml = QRCodeHtml;
3492
+ async initWithQR(qrCode) {
3493
+ super.init();
3494
+ this.populateQRCode(qrCode);
3495
+ }
3496
+ async populateQRCode(qrUrl) {
3497
+ const qrcodeContainer = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-code-container");
3498
+ if (qrcodeContainer) {
3499
+ const qrCodeElement = await QRCode.toCanvas(qrUrl, {
3500
+ width: 200,
3501
+ margin: 0
3502
+ });
3503
+ if (qrcodeContainer.firstElementChild !== null) qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
3504
+ else qrcodeContainer.appendChild(qrCodeElement);
3505
+ const qrPlaceholder = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-placeholder");
3506
+ if (qrPlaceholder) qrPlaceholder.style.display = "none";
3507
+ } else console.error("QRCode Container not found");
3508
+ }
3461
3509
  };
3462
-
3463
- class RemoteConnectionModal extends EmbeddedModal {
3464
- constructor() {
3465
- super(...arguments);
3466
- this.contentStyles = css$1;
3467
- this.contentHtml = QRCodeHtml;
3468
- }
3469
- initWithQR(qrCode) {
3470
- const _super = Object.create(null, {
3471
- init: { get: () => super.init }
3472
- });
3473
- return __awaiter(this, void 0, void 0, function* () {
3474
- _super.init.call(this);
3475
- this.populateQRCode(qrCode);
3476
- });
3477
- }
3478
- populateQRCode(qrUrl) {
3479
- var _a;
3480
- return __awaiter(this, void 0, void 0, function* () {
3481
- const qrcodeContainer = (_a = this.dom) === null || _a === void 0 ? void 0 : _a.getElementById('mobile-wallet-adapter-embedded-modal-qr-code-container');
3482
- if (qrcodeContainer) {
3483
- const qrCodeElement = yield QRCode.toCanvas(qrUrl, { width: 200, margin: 0 });
3484
- if (qrcodeContainer.firstElementChild !== null) {
3485
- qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
3486
- }
3487
- else
3488
- qrcodeContainer.appendChild(qrCodeElement);
3489
- }
3490
- else {
3491
- console.error('QRCode Container not found');
3492
- }
3493
- });
3494
- }
3495
- }
3496
3510
  const QRCodeHtml = `
3497
3511
  <div class="mobile-wallet-adapter-embedded-modal-qr-content">
3498
3512
  <div>
@@ -3508,7 +3522,9 @@ const QRCodeHtml = `
3508
3522
  Open your wallet and scan this code
3509
3523
  </h4>
3510
3524
  </div>
3511
- <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container"></div>
3525
+ <div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
3526
+ <div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
3527
+ </div>
3512
3528
  </div>
3513
3529
  </div>
3514
3530
  <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
@@ -3535,7 +3551,7 @@ const QRCodeHtml = `
3535
3551
  </div>
3536
3552
  </div>
3537
3553
  `;
3538
- const css$1 = `
3554
+ const css$4 = `
3539
3555
  .mobile-wallet-adapter-embedded-modal-qr-content {
3540
3556
  display: flex;
3541
3557
  margin-top: 10px;
@@ -3579,6 +3595,16 @@ const css$1 = `
3579
3595
  margin-left: auto;
3580
3596
  }
3581
3597
 
3598
+ .mobile-wallet-adapter-embedded-modal-qr-placeholder {
3599
+ margin-left: auto;
3600
+ min-width: 200px;
3601
+ min-height: 200px;
3602
+ background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
3603
+ background-size: 200%;
3604
+ animation: placeholderAnimate 2.7s linear infinite;
3605
+ border-radius: 12px;
3606
+ }
3607
+
3582
3608
  .mobile-wallet-adapter-embedded-modal-divider {
3583
3609
  margin-top: 20px;
3584
3610
  padding-left: 10px;
@@ -3651,6 +3677,15 @@ const css$1 = `
3651
3677
  .mobile-wallet-adapter-embedded-modal-qr-code-container {
3652
3678
  margin: auto;
3653
3679
  }
3680
+ .mobile-wallet-adapter-embedded-modal-qr-placeholder {
3681
+ margin: auto;
3682
+ }
3683
+ }
3684
+
3685
+ /* QR Placeholder */
3686
+ @keyframes placeholderAnimate {
3687
+ 0% { background-position: 200% 0; }
3688
+ 100% { background-position: -200% 0; }
3654
3689
  }
3655
3690
 
3656
3691
  /* Spinner */
@@ -3731,962 +3766,1173 @@ const css$1 = `
3731
3766
  animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
3732
3767
  }
3733
3768
  `;
3734
-
3735
- const icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=';
3736
-
3737
- function fromUint8Array(byteArray) {
3738
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
3769
+ //#endregion
3770
+ //#region src/embedded-modal/localConnectionModal.ts
3771
+ var LocalConnectionModal = class extends EmbeddedModal {
3772
+ contentStyles = css$3;
3773
+ contentHtml = ErrorDialogHtml$3;
3774
+ initWithCallback(callback) {
3775
+ super.init();
3776
+ this.#prepareLaunchAction(callback);
3777
+ }
3778
+ #prepareLaunchAction(callback) {
3779
+ const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
3780
+ const listener = async () => {
3781
+ launchButton?.removeEventListener("click", listener);
3782
+ this.close();
3783
+ callback();
3784
+ };
3785
+ launchButton?.addEventListener("click", listener);
3786
+ }
3787
+ };
3788
+ const ErrorDialogHtml$3 = `
3789
+ <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">
3790
+ <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"/>
3791
+ <mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
3792
+ <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
3793
+ </mask>
3794
+ <g mask="url(#mask0_189_522)">
3795
+ <mask id="mask1_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
3796
+ <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
3797
+ </mask>
3798
+ <g mask="url(#mask1_189_522)">
3799
+ <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"/>
3800
+ </g>
3801
+ </g>
3802
+ </svg>
3803
+ <div class="mobile-wallet-adapter-embedded-modal-title">Ready to connect!</div>
3804
+ <div>
3805
+ <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
3806
+ Connect Wallet
3807
+ </button>
3808
+ </div>
3809
+ `;
3810
+ const css$3 = `
3811
+ .mobile-wallet-adapter-embedded-modal-close {
3812
+ display: none;
3739
3813
  }
3740
- function toUint8Array(base64EncodedByteArray) {
3741
- return new Uint8Array(window
3742
- .atob(base64EncodedByteArray)
3743
- .split('')
3744
- .map((c) => c.charCodeAt(0)));
3814
+ .mobile-wallet-adapter-embedded-modal-content {
3815
+ text-align: center;
3816
+ min-width: 300px;
3745
3817
  }
3746
-
3747
- 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;
3748
- const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
3749
- const SolanaMobileWalletAdapterRemoteWalletName = 'Remote Mobile Wallet Adapter';
3750
- const SIGNATURE_LENGTH_IN_BYTES = 64;
3751
- const DEFAULT_FEATURES = [SolanaSignAndSendTransaction, SolanaSignTransaction, SolanaSignMessage, SolanaSignIn];
3752
- class LocalSolanaMobileWalletAdapterWallet {
3753
- constructor(config) {
3754
- _LocalSolanaMobileWalletAdapterWallet_instances.add(this);
3755
- _LocalSolanaMobileWalletAdapterWallet_listeners.set(this, {});
3756
- _LocalSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
3757
- _LocalSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterWalletName);
3758
- _LocalSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
3759
- _LocalSolanaMobileWalletAdapterWallet_icon.set(this, icon);
3760
- _LocalSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
3761
- _LocalSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
3762
- _LocalSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
3763
- _LocalSolanaMobileWalletAdapterWallet_connecting.set(this, false);
3764
- /**
3765
- * Every time the connection is recycled in some way (eg. `disconnect()` is called)
3766
- * increment this and use it to make sure that `transact` calls from the previous
3767
- * 'generation' don't continue to do work and throw exceptions.
3768
- */
3769
- _LocalSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
3770
- _LocalSolanaMobileWalletAdapterWallet_chains.set(this, []);
3771
- _LocalSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
3772
- _LocalSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
3773
- _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
3774
- _LocalSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
3775
- var _a;
3776
- ((_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]);
3777
- return () => __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
3778
- });
3779
- _LocalSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
3780
- if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
3781
- return { accounts: this.accounts };
3782
- }
3783
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
3784
- try {
3785
- if (silent) {
3786
- const cachedAuthorization = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
3787
- if (cachedAuthorization) {
3788
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, cachedAuthorization.capabilities);
3789
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorization);
3790
- }
3791
- else {
3792
- return { accounts: this.accounts };
3793
- }
3794
- }
3795
- else {
3796
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
3797
- }
3798
- }
3799
- catch (e) {
3800
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
3801
- }
3802
- finally {
3803
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3804
- }
3805
- return { accounts: this.accounts };
3806
- }));
3807
- _LocalSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
3808
- try {
3809
- const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
3810
- if (cachedAuthorizationResult) {
3811
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3812
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
3813
- return cachedAuthorizationResult;
3814
- }
3815
- const selectedChain = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"));
3816
- return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3817
- const [capabilities, mwaAuthorizationResult] = yield Promise.all([
3818
- wallet.getCapabilities(),
3819
- wallet.authorize({
3820
- chain: selectedChain,
3821
- identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
3822
- sign_in_payload: signInPayload,
3823
- })
3824
- ]);
3825
- const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
3826
- const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
3827
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3828
- Promise.all([
3829
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
3830
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
3831
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
3832
- ]);
3833
- return authorization;
3834
- }));
3835
- }
3836
- catch (e) {
3837
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
3838
- }
3839
- }));
3840
- _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
3841
- var _a;
3842
- const didPublicKeysChange =
3843
- // Case 1: We started from having no authorization.
3844
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
3845
- // Case 2: The number of authorized accounts changed.
3846
- ((_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
3847
- // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
3848
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
3849
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, authorization);
3850
- if (didPublicKeysChange) {
3851
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
3852
- }
3853
- }));
3854
- _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
3855
- // TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
3856
- const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
3857
- const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
3858
- const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
3859
- SolanaSignTransaction in this.features !== supportsSignTransaction;
3860
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, ((supportsSignAndSendTransaction || (!supportsSignAndSendTransaction && !supportsSignTransaction)) && {
3861
- [SolanaSignAndSendTransaction]: {
3862
- version: '1.0.0',
3863
- supportedTransactionVersions: ['legacy', 0],
3864
- signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
3865
- },
3866
- })), (supportsSignTransaction && {
3867
- [SolanaSignTransaction]: {
3868
- version: '1.0.0',
3869
- supportedTransactionVersions: ['legacy', 0],
3870
- signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
3871
- },
3872
- })));
3873
- if (didCapabilitiesChange) {
3874
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
3875
- }
3876
- }));
3877
- _LocalSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
3878
- var _b, _c;
3879
- try {
3880
- const [capabilities, mwaAuthorizationResult] = yield Promise.all([
3881
- (_c = (_b = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
3882
- wallet.authorize({
3883
- auth_token: authToken,
3884
- identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
3885
- chain: chain
3886
- })
3887
- ]);
3888
- const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
3889
- const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
3890
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3891
- Promise.all([
3892
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
3893
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
3894
- ]);
3895
- }
3896
- catch (e) {
3897
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
3898
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
3899
- }
3900
- }));
3901
- _LocalSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
3902
- var _d;
3903
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
3904
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
3905
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, (_d = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _d++, _d));
3906
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, undefined);
3907
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
3908
- }));
3909
- _LocalSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
3910
- var _e;
3911
- const walletUriBase = (_e = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _e === void 0 ? void 0 : _e.wallet_uri_base;
3912
- const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
3913
- const currentConnectionGeneration = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
3914
- try {
3915
- return yield index_browser.transact(callback, config);
3916
- }
3917
- catch (e) {
3918
- if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
3919
- yield new Promise(() => { }); // Never resolve.
3920
- }
3921
- if (e instanceof Error &&
3922
- e.name === 'SolanaMobileWalletAdapterError' &&
3923
- e.code === 'ERROR_WALLET_NOT_FOUND') {
3924
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
3925
- }
3926
- throw e;
3927
- }
3928
- }));
3929
- _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
3930
- if (!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f"))
3931
- throw new Error('Wallet not connected');
3932
- return { authToken: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").chain };
3933
- });
3934
- _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
3935
- return accounts.map((account) => {
3936
- var _a, _b;
3937
- const publicKey = toUint8Array(account.address);
3938
- return {
3939
- address: base58.encode(publicKey),
3940
- publicKey,
3941
- label: account.label,
3942
- icon: account.icon,
3943
- chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"),
3944
- // TODO: get supported features from getCapabilities API
3945
- features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
3946
- };
3947
- });
3948
- });
3949
- _LocalSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
3950
- const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3951
- try {
3952
- const base64Transactions = transactions.map((tx) => { return fromUint8Array(tx); });
3953
- return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3954
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
3955
- const signedTransactions = (yield wallet.signTransactions({
3956
- payloads: base64Transactions,
3957
- })).signed_payloads.map(toUint8Array);
3958
- return signedTransactions;
3959
- }));
3960
- }
3961
- catch (e) {
3962
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
3963
- }
3964
- }));
3965
- _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
3966
- const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
3967
- try {
3968
- return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
3969
- const [capabilities, _1] = yield Promise.all([
3970
- wallet.getCapabilities(),
3971
- __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
3972
- ]);
3973
- if (capabilities.supports_sign_and_send_transactions) {
3974
- const base64Transaction = fromUint8Array(transaction);
3975
- const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [base64Transaction] }))).signatures.map(toUint8Array);
3976
- return signatures[0];
3977
- }
3978
- else {
3979
- throw new Error('connected wallet does not support signAndSendTransaction');
3980
- }
3981
- }));
3982
- }
3983
- catch (e) {
3984
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
3985
- }
3986
- }));
3987
- _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3988
- const outputs = [];
3989
- for (const input of inputs) {
3990
- const signature = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options);
3991
- outputs.push({ signature });
3992
- }
3993
- return outputs;
3994
- }));
3995
- _LocalSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
3996
- return (yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
3997
- .map((signedTransaction) => {
3998
- return { signedTransaction };
3999
- });
4000
- }));
4001
- _LocalSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4002
- const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4003
- const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
4004
- const messages = inputs.map(({ message }) => fromUint8Array(message));
4005
- try {
4006
- return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4007
- yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4008
- const signedMessages = (yield wallet.signMessages({
4009
- addresses: addresses,
4010
- payloads: messages,
4011
- })).signed_payloads.map(toUint8Array);
4012
- return signedMessages.map((signedMessage) => {
4013
- return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
4014
- });
4015
- }));
4016
- }
4017
- catch (e) {
4018
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4019
- }
4020
- }));
4021
- _LocalSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4022
- const outputs = [];
4023
- if (inputs.length > 1) {
4024
- for (const input of inputs) {
4025
- outputs.push(yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
4026
- }
4027
- }
4028
- else {
4029
- return [yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
4030
- }
4031
- return outputs;
4032
- }));
4033
- _LocalSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
4034
- var _f, _g, _h;
4035
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
4036
- try {
4037
- 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 }));
4038
- if (!authorizationResult.sign_in_result) {
4039
- throw new Error("Sign in failed, no sign in result returned by wallet");
4040
- }
4041
- const signedInAddress = authorizationResult.sign_in_result.address;
4042
- const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
4043
- return {
4044
- account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
4045
- address: base58.encode(toUint8Array(signedInAddress))
4046
- }), { 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 }),
4047
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4048
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
4049
- };
4050
- }
4051
- catch (e) {
4052
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4053
- }
4054
- finally {
4055
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
4056
- }
4057
- }));
4058
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
4059
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
4060
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, config.chains);
4061
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
4062
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
4063
- __classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, {
4064
- // In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
4065
- // signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
4066
- // 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
4067
- // assume both are supported here. The features will be updated based on the actual connected
4068
- // wallets capabilities during connection regardless, so this is safe.
4069
- [SolanaSignAndSendTransaction]: {
4070
- version: '1.0.0',
4071
- supportedTransactionVersions: ['legacy', 0],
4072
- signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4073
- },
4074
- [SolanaSignTransaction]: {
4075
- version: '1.0.0',
4076
- supportedTransactionVersions: ['legacy', 0],
4077
- signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4078
- },
4079
- });
4080
- }
4081
- get version() {
4082
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_version, "f");
4083
- }
4084
- get name() {
4085
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_name, "f");
4086
- }
4087
- get url() {
4088
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_url, "f");
4089
- }
4090
- get icon() {
4091
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_icon, "f");
4092
- }
4093
- get chains() {
4094
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f");
4095
- }
4096
- get features() {
4097
- return Object.assign({ [StandardConnect]: {
4098
- version: '1.0.0',
4099
- connect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connect, "f"),
4100
- }, [StandardDisconnect]: {
4101
- version: '1.0.0',
4102
- disconnect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f"),
4103
- }, [StandardEvents]: {
4104
- version: '1.0.0',
4105
- on: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_on, "f"),
4106
- }, [SolanaSignMessage]: {
4107
- version: '1.0.0',
4108
- signMessage: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signMessage, "f"),
4109
- }, [SolanaSignIn]: {
4110
- version: '1.0.0',
4111
- signIn: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signIn, "f"),
4112
- } }, __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
4113
- }
4114
- get accounts() {
4115
- var _a, _b;
4116
- return (_b = (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
4117
- }
4118
- get connected() {
4119
- return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4120
- }
4121
- get isAuthorized() {
4122
- return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4123
- }
4124
- get currentAuthorization() {
4125
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
4126
- }
4127
- get cachedAuthorizationResult() {
4128
- return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4129
- }
3818
+ .mobile-wallet-adapter-embedded-modal-launch-icon {
3819
+ margin-top: 24px;
4130
3820
  }
4131
- _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) {
4132
- var _a;
4133
- // eslint-disable-next-line prefer-spread
4134
- (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
4135
- }, _LocalSolanaMobileWalletAdapterWallet_off = function _LocalSolanaMobileWalletAdapterWallet_off(event, listener) {
4136
- var _a;
4137
- __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);
4138
- };
4139
- class RemoteSolanaMobileWalletAdapterWallet {
4140
- constructor(config) {
4141
- _RemoteSolanaMobileWalletAdapterWallet_instances.add(this);
4142
- _RemoteSolanaMobileWalletAdapterWallet_listeners.set(this, {});
4143
- _RemoteSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
4144
- _RemoteSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterRemoteWalletName);
4145
- _RemoteSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
4146
- _RemoteSolanaMobileWalletAdapterWallet_icon.set(this, icon);
4147
- _RemoteSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
4148
- _RemoteSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
4149
- _RemoteSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
4150
- _RemoteSolanaMobileWalletAdapterWallet_connecting.set(this, false);
4151
- /**
4152
- * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4153
- * increment this and use it to make sure that `transact` calls from the previous
4154
- * 'generation' don't continue to do work and throw exceptions.
4155
- */
4156
- _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
4157
- _RemoteSolanaMobileWalletAdapterWallet_chains.set(this, []);
4158
- _RemoteSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
4159
- _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
4160
- _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
4161
- _RemoteSolanaMobileWalletAdapterWallet_hostAuthority.set(this, void 0);
4162
- _RemoteSolanaMobileWalletAdapterWallet_session.set(this, void 0);
4163
- _RemoteSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
4164
- var _a;
4165
- ((_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]);
4166
- return () => __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
4167
- });
4168
- _RemoteSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
4169
- if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
4170
- return { accounts: this.accounts };
4171
- }
4172
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true);
4173
- try {
4174
- yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
4175
- }
4176
- catch (e) {
4177
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4178
- }
4179
- finally {
4180
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4181
- }
4182
- return { accounts: this.accounts };
4183
- }));
4184
- _RemoteSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
4185
- try {
4186
- const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4187
- if (cachedAuthorizationResult) {
4188
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4189
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
4190
- return cachedAuthorizationResult;
4191
- }
4192
- if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f"))
4193
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined, "f");
4194
- const selectedChain = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"));
4195
- return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4196
- const [capabilities, mwaAuthorizationResult] = yield Promise.all([
4197
- wallet.getCapabilities(),
4198
- wallet.authorize({
4199
- chain: selectedChain,
4200
- identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
4201
- sign_in_payload: signInPayload,
4202
- })
4203
- ]);
4204
- const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
4205
- const authorizationResult = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
4206
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4207
- Promise.all([
4208
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
4209
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorizationResult),
4210
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorizationResult),
4211
- ]);
4212
- return authorizationResult;
4213
- }));
4214
- }
4215
- catch (e) {
4216
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4217
- }
4218
- }));
4219
- _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
4220
- var _a;
4221
- const didPublicKeysChange =
4222
- // Case 1: We started from having no authorization.
4223
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
4224
- // Case 2: The number of authorized accounts changed.
4225
- ((_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
4226
- // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
4227
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4228
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, authorization);
4229
- if (didPublicKeysChange) {
4230
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
4231
- }
4232
- }));
4233
- _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
4234
- // TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
4235
- const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
4236
- const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions ||
4237
- capabilities.features.includes('solana:signAndSendTransaction');
4238
- const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
4239
- SolanaSignTransaction in this.features !== supportsSignTransaction;
4240
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, (supportsSignAndSendTransaction && {
4241
- [SolanaSignAndSendTransaction]: {
4242
- version: '1.0.0',
4243
- supportedTransactionVersions: capabilities.supported_transaction_versions,
4244
- signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4245
- },
4246
- })), (supportsSignTransaction && {
4247
- [SolanaSignTransaction]: {
4248
- version: '1.0.0',
4249
- supportedTransactionVersions: capabilities.supported_transaction_versions,
4250
- signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4251
- },
4252
- })));
4253
- if (didCapabilitiesChange) {
4254
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
4255
- }
4256
- }));
4257
- _RemoteSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
4258
- var _b, _c;
4259
- try {
4260
- const [capabilities, mwaAuthorizationResult] = yield Promise.all([
4261
- (_c = (_b = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
4262
- wallet.authorize({
4263
- auth_token: authToken,
4264
- identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
4265
- chain: chain
4266
- })
4267
- ]);
4268
- const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
4269
- const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
4270
- // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4271
- Promise.all([
4272
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
4273
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
4274
- ]);
4275
- }
4276
- catch (e) {
4277
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
4278
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4279
- }
4280
- }));
4281
- _RemoteSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
4282
- var _d;
4283
- var _e;
4284
- (_d = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) === null || _d === void 0 ? void 0 : _d.close();
4285
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
4286
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4287
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, (_e = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _e++, _e));
4288
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, undefined);
4289
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined);
4290
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
4291
- }));
4292
- _RemoteSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
4293
- var _f;
4294
- const walletUriBase = (_f = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _f === void 0 ? void 0 : _f.wallet_uri_base;
4295
- const baseConfig = walletUriBase ? { baseUri: walletUriBase } : undefined;
4296
- const remoteConfig = Object.assign(Object.assign({}, baseConfig), { remoteHostAuthority: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, "f") });
4297
- const currentConnectionGeneration = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
4298
- const modal = new RemoteConnectionModal();
4299
- if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) {
4300
- return callback(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f").wallet);
4301
- }
4302
- try {
4303
- const { associationUrl, close, wallet } = yield index_browser.startRemoteScenario(remoteConfig);
4304
- const removeCloseListener = modal.addEventListener('close', (event) => {
4305
- if (event)
4306
- close();
4307
- });
4308
- modal.initWithQR(associationUrl.toString());
4309
- modal.open();
4310
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, { close, wallet: yield wallet }, "f");
4311
- removeCloseListener();
4312
- modal.close();
4313
- return yield callback(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f").wallet);
4314
- }
4315
- catch (e) {
4316
- modal.close();
4317
- if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
4318
- yield new Promise(() => { }); // Never resolve.
4319
- }
4320
- if (e instanceof Error &&
4321
- e.name === 'SolanaMobileWalletAdapterError' &&
4322
- e.code === 'ERROR_WALLET_NOT_FOUND') {
4323
- yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
4324
- }
4325
- throw e;
4326
- }
4327
- }));
4328
- _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
4329
- if (!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f"))
4330
- throw new Error('Wallet not connected');
4331
- return { authToken: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").chain };
4332
- });
4333
- _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
4334
- return accounts.map((account) => {
4335
- var _a, _b;
4336
- const publicKey = toUint8Array(account.address);
4337
- return {
4338
- address: base58.encode(publicKey),
4339
- publicKey,
4340
- label: account.label,
4341
- icon: account.icon,
4342
- chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"),
4343
- // TODO: get supported features from getCapabilities API
4344
- features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
4345
- };
4346
- });
4347
- });
4348
- _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
4349
- const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4350
- try {
4351
- return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4352
- yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4353
- const signedTransactions = (yield wallet.signTransactions({
4354
- payloads: transactions.map(fromUint8Array),
4355
- })).signed_payloads.map(toUint8Array);
4356
- return signedTransactions;
4357
- }));
4358
- }
4359
- catch (e) {
4360
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4361
- }
4362
- }));
4363
- _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
4364
- const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4365
- try {
4366
- return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4367
- const [capabilities, _1] = yield Promise.all([
4368
- wallet.getCapabilities(),
4369
- __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
4370
- ]);
4371
- if (capabilities.supports_sign_and_send_transactions) {
4372
- const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [fromUint8Array(transaction)] }))).signatures.map(toUint8Array);
4373
- return signatures[0];
4374
- }
4375
- else {
4376
- throw new Error('connected wallet does not support signAndSendTransaction');
4377
- }
4378
- }));
4379
- }
4380
- catch (e) {
4381
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4382
- }
4383
- }));
4384
- _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4385
- const outputs = [];
4386
- for (const input of inputs) {
4387
- const signature = (yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options));
4388
- outputs.push({ signature });
4389
- }
4390
- return outputs;
4391
- }));
4392
- _RemoteSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4393
- return (yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
4394
- .map((signedTransaction) => {
4395
- return { signedTransaction };
4396
- });
4397
- }));
4398
- _RemoteSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4399
- const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
4400
- const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
4401
- const messages = inputs.map(({ message }) => fromUint8Array(message));
4402
- try {
4403
- return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
4404
- yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
4405
- const signedMessages = (yield wallet.signMessages({
4406
- addresses: addresses,
4407
- payloads: messages,
4408
- })).signed_payloads.map(toUint8Array);
4409
- return signedMessages.map((signedMessage) => {
4410
- return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
4411
- });
4412
- }));
4413
- }
4414
- catch (e) {
4415
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4416
- }
4417
- }));
4418
- _RemoteSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
4419
- const outputs = [];
4420
- if (inputs.length > 1) {
4421
- for (const input of inputs) {
4422
- outputs.push(yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
4423
- }
4424
- }
4425
- else {
4426
- return [yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
4427
- }
4428
- return outputs;
4429
- }));
4430
- _RemoteSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
4431
- var _g, _h, _j;
4432
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true);
4433
- try {
4434
- 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 }));
4435
- if (!authorizationResult.sign_in_result) {
4436
- throw new Error("Sign in failed, no sign in result returned by wallet");
4437
- }
4438
- const signedInAddress = authorizationResult.sign_in_result.address;
4439
- const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
4440
- return {
4441
- account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
4442
- address: base58.encode(toUint8Array(signedInAddress))
4443
- }), { 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 }),
4444
- signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4445
- signature: toUint8Array(authorizationResult.sign_in_result.signature)
4446
- };
4447
- }
4448
- catch (e) {
4449
- throw new Error((e instanceof Error && e.message) || 'Unknown error');
4450
- }
4451
- finally {
4452
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
4453
- }
4454
- }));
4455
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
4456
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
4457
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, config.chains);
4458
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
4459
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, config.remoteHostAuthority);
4460
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
4461
- __classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, {
4462
- // In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
4463
- // signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
4464
- // 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
4465
- // assume both are supported here. The features will be updated based on the actual connected
4466
- // wallets capabilities during connection regardless, so this is safe.
4467
- [SolanaSignAndSendTransaction]: {
4468
- version: '1.0.0',
4469
- supportedTransactionVersions: ['legacy', 0],
4470
- signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
4471
- },
4472
- [SolanaSignTransaction]: {
4473
- version: '1.0.0',
4474
- supportedTransactionVersions: ['legacy', 0],
4475
- signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
4476
- },
4477
- });
4478
- }
4479
- get version() {
4480
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_version, "f");
4481
- }
4482
- get name() {
4483
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_name, "f");
4484
- }
4485
- get url() {
4486
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_url, "f");
4487
- }
4488
- get icon() {
4489
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_icon, "f");
4490
- }
4491
- get chains() {
4492
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f");
4493
- }
4494
- get features() {
4495
- return Object.assign({ [StandardConnect]: {
4496
- version: '1.0.0',
4497
- connect: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connect, "f"),
4498
- }, [StandardDisconnect]: {
4499
- version: '1.0.0',
4500
- disconnect: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_disconnect, "f"),
4501
- }, [StandardEvents]: {
4502
- version: '1.0.0',
4503
- on: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_on, "f"),
4504
- }, [SolanaSignMessage]: {
4505
- version: '1.0.0',
4506
- signMessage: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signMessage, "f"),
4507
- }, [SolanaSignIn]: {
4508
- version: '1.0.0',
4509
- signIn: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signIn, "f"),
4510
- } }, __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
4511
- }
4512
- get accounts() {
4513
- var _a, _b;
4514
- return (_b = (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
4515
- }
4516
- get connected() {
4517
- return !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f") && !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4518
- }
4519
- get isAuthorized() {
4520
- return !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4521
- }
4522
- get currentAuthorization() {
4523
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
4524
- }
4525
- get cachedAuthorizationResult() {
4526
- return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
4527
- }
3821
+ .mobile-wallet-adapter-embedded-modal-title {
3822
+ margin: 18px 100px 30px 100px;
3823
+ color: #000000;
3824
+ font-size: 2.75em;
3825
+ font-weight: 600;
4528
3826
  }
4529
- _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) {
4530
- var _a;
4531
- // eslint-disable-next-line prefer-spread
4532
- (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
4533
- }, _RemoteSolanaMobileWalletAdapterWallet_off = function _RemoteSolanaMobileWalletAdapterWallet_off(event, listener) {
4534
- var _a;
4535
- __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);
4536
- };
4537
-
4538
- var __classPrivateFieldSet = function (receiver, state, value, kind, f) {
4539
- if (kind === "m") throw new TypeError("Private method is not writable");
4540
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4541
- 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");
4542
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
4543
- };
4544
- var __classPrivateFieldGet = function (receiver, state, kind, f) {
4545
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4546
- 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");
4547
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
4548
- };
4549
- var _RegisterWalletEvent_detail;
4550
- /**
4551
- * Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
4552
- *
4553
- * This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
4554
- * ready to be registered.
4555
- *
4556
- * This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
4557
- * the app that the app is ready to register the Wallet.
4558
- *
4559
- * This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
4560
- * as the app is ready whether the Wallet loads before or after the app.
4561
- *
4562
- * @param wallet Wallet to register.
4563
- *
4564
- * @group Wallet
4565
- */
4566
- function registerWallet(wallet) {
4567
- const callback = ({ register }) => register(wallet);
4568
- try {
4569
- window.dispatchEvent(new RegisterWalletEvent(callback));
4570
- }
4571
- catch (error) {
4572
- console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
4573
- }
4574
- try {
4575
- window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
4576
- }
4577
- catch (error) {
4578
- console.error('wallet-standard:app-ready event listener could not be added\n', error);
4579
- }
3827
+ .mobile-wallet-adapter-embedded-modal-launch-action {
3828
+ display: block;
3829
+ width: 100%;
3830
+ height: 56px;
3831
+ font-size: 1.25em;
3832
+ background: #000000;
3833
+ color: #FFFFFF;
3834
+ border-radius: 18px;
4580
3835
  }
4581
- class RegisterWalletEvent extends Event {
4582
- constructor(callback) {
4583
- super('wallet-standard:register-wallet', {
4584
- bubbles: false,
4585
- cancelable: false,
4586
- composed: false,
4587
- });
4588
- _RegisterWalletEvent_detail.set(this, void 0);
4589
- __classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
4590
- }
4591
- get detail() {
4592
- return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
3836
+ /* Smaller screens */
3837
+ @media all and (max-width: 600px) {
3838
+ .mobile-wallet-adapter-embedded-modal-title {
3839
+ font-size: 1.5em;
3840
+ margin-right: 12px;
3841
+ margin-left: 12px;
4593
3842
  }
4594
- get type() {
4595
- return 'wallet-standard:register-wallet';
3843
+ }
3844
+ `;
3845
+ //#endregion
3846
+ //#region src/embedded-modal/loopbackBlockedModal.ts
3847
+ var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
3848
+ contentStyles = css$2;
3849
+ get contentHtml() {
3850
+ 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";
3851
+ return ErrorDialogHtml$2.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
3852
+ }
3853
+ async init() {
3854
+ super.init();
3855
+ this.#prepareLaunchAction();
3856
+ }
3857
+ #prepareLaunchAction() {
3858
+ const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
3859
+ const listener = async (event) => {
3860
+ launchButton?.removeEventListener("click", listener);
3861
+ this.close(event);
3862
+ };
3863
+ launchButton?.addEventListener("click", listener);
3864
+ }
3865
+ };
3866
+ const ErrorDialogHtml$2 = `
3867
+ <div class="mobile-wallet-adapter-embedded-modal-header">
3868
+ Local Wallet Connection
3869
+ </div>
3870
+ <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
3871
+ <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"/>
3872
+ <mask id="mask0_147_1364" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
3873
+ <rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
3874
+ </mask>
3875
+ <g mask="url(#mask0_147_1364)">
3876
+ <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"/>
3877
+ </g>
3878
+ </svg>
3879
+ <div class="mobile-wallet-adapter-embedded-modal-title">
3880
+ Your wallet connection is blocked
3881
+ </div>
3882
+ <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
3883
+ Visit site settings in the address bar and allow "Apps on Device".
3884
+ </div>
3885
+
3886
+ <div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
3887
+ <div class="mobile-wallet-adapter-embedded-modal-footer">
3888
+ <div class="mobile-wallet-adapter-embedded-modal-details">
3889
+ <!-- Clickable header (label associated with the checkbox) -->
3890
+ <label for="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-header">
3891
+ <!-- Hidden checkbox to track state -->
3892
+ <input type="checkbox" id="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-input">
3893
+ <span class="mobile-wallet-adapter-embedded-modal-details-collapsible-header-label">
3894
+ See details
3895
+ </span>
3896
+ <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">
3897
+ <mask id="mask0_147_1382" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
3898
+ <rect width="24" height="24" fill="#D9D9D9"/>
3899
+ </mask>
3900
+ <g mask="url(#mask0_147_1382)">
3901
+ <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"/>
3902
+ </g>
3903
+ </svg>
3904
+ </label>
3905
+
3906
+ <!-- Content to show/hide -->
3907
+ <ul class="mobile-wallet-adapter-embedded-modal-details-collapsible-content">
3908
+ <li>{{PERMISSION_INSTRUCTION_DETAIL}}</li>
3909
+ <li>Allow "Apps on Device"</li>
3910
+ </ul>
3911
+ </div>
3912
+ </div>
3913
+ <div>
3914
+ <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
3915
+ Got it
3916
+ </button>
3917
+ </div>
3918
+ `;
3919
+ const css$2 = `
3920
+ .mobile-wallet-adapter-embedded-modal-close {
3921
+ display: none;
3922
+ }
3923
+ .mobile-wallet-adapter-embedded-modal-content {
3924
+ text-align: center;
3925
+ }
3926
+ .mobile-wallet-adapter-embedded-modal-header {
3927
+ margin: 18px auto 30px auto;
3928
+ color: #7D9093;
3929
+ font-size: 1.0em;
3930
+ font-weight: 500;
3931
+ }
3932
+ .mobile-wallet-adapter-embedded-modal-title {
3933
+ margin: 18px 100px auto 100px;
3934
+ color: #000000;
3935
+ font-size: 2.75em;
3936
+ font-weight: 600;
3937
+ }
3938
+ .mobile-wallet-adapter-embedded-modal-subtitle {
3939
+ margin: 12px 60px 30px 60px;
3940
+ color: #7D9093;
3941
+ font-size: 1.25em;
3942
+ font-weight: 400;
3943
+ }
3944
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-header {
3945
+ display: flex;
3946
+ flex-direction: row;
3947
+ justify-content: space-between;
3948
+ margin: 10px auto 10px auto;
3949
+ color: #000000;
3950
+ font-size: 1.5em;
3951
+ font-weight: 600;
3952
+ cursor: pointer; /* Show pointer on hover */
3953
+ transition: background 0.2s ease; /* Smooth background change */
3954
+ }
3955
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
3956
+ transition: rotate 0.3s ease;
3957
+ }
3958
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-input {
3959
+ display: none; /* Hide the checkbox */
3960
+ }
3961
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
3962
+ margin: 0px auto 40px auto;
3963
+ max-height: 0px; /* Collapse content */
3964
+ overflow: hidden; /* Hide overflow when collapsed */
3965
+ transition: max-height 0.3s ease; /* Smooth transition */
3966
+ }
3967
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-content li {
3968
+ margin: 20px auto;
3969
+ color: #000000;
3970
+ font-size: 1.25em;
3971
+ font-weight: 400;
3972
+ text-align: left;
3973
+ }
3974
+ /* When checkbox is checked, show content */
3975
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) ~ .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
3976
+ max-height: 300px;
3977
+ }
3978
+ .mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) > .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
3979
+ rotate: 180deg;
3980
+ }
3981
+ .mobile-wallet-adapter-embedded-modal-launch-action {
3982
+ display: block;
3983
+ width: 100%;
3984
+ height: 56px;
3985
+ /*margin-top: 40px;*/
3986
+ font-size: 1.25em;
3987
+ /*line-height: 24px;*/
3988
+ /*letter-spacing: -1%;*/
3989
+ background: #000000;
3990
+ color: #FFFFFF;
3991
+ border-radius: 18px;
3992
+ }
3993
+ /* Smaller screens */
3994
+ @media all and (max-width: 600px) {
3995
+ .mobile-wallet-adapter-embedded-modal-title {
3996
+ font-size: 1.75em;
3997
+ margin-right: 12px;
3998
+ margin-left: 12px;
4596
3999
  }
4597
- /** @deprecated */
4598
- preventDefault() {
4599
- throw new Error('preventDefault cannot be called');
4000
+ .mobile-wallet-adapter-embedded-modal-subtitle {
4001
+ margin-right: 12px;
4002
+ margin-left: 12px;
4600
4003
  }
4601
- /** @deprecated */
4602
- stopImmediatePropagation() {
4603
- throw new Error('stopImmediatePropagation cannot be called');
4004
+ }
4005
+ `;
4006
+ //#endregion
4007
+ //#region src/embedded-modal/loopbackPermissionModal.ts
4008
+ var LoopbackPermissionModal = class extends EmbeddedModal {
4009
+ contentStyles = css$1;
4010
+ contentHtml = ErrorDialogHtml$1;
4011
+ async init() {
4012
+ super.init();
4013
+ this.#prepareLaunchAction();
4014
+ }
4015
+ #prepareLaunchAction() {
4016
+ const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
4017
+ const listener = async () => {
4018
+ launchButton?.removeEventListener("click", listener);
4019
+ try {
4020
+ await fetch("http://localhost");
4021
+ } catch {}
4022
+ this.close();
4023
+ };
4024
+ launchButton?.addEventListener("click", listener);
4025
+ }
4026
+ };
4027
+ const ErrorDialogHtml$1 = `
4028
+ <div class="mobile-wallet-adapter-embedded-modal-title">Allow connections to your wallet</div>
4029
+ <div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
4030
+ Tap "Allow" on the next screen
4031
+ </div>
4032
+ <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">
4033
+ <rect width="281" height="83" rx="22" fill="#F0F3F5"/>
4034
+ <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"/>
4035
+ <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"/>
4036
+ <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"/>
4037
+ <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"/>
4038
+ <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"/>
4039
+ <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"/>
4040
+ <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"/>
4041
+ <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"/>
4042
+ <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"/>
4043
+ <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"/>
4044
+ <rect x="18" y="17" width="246" height="7" rx="3.5" fill="#7D9093" fill-opacity="0.26"/>
4045
+ <rect x="18" y="33" width="82" height="7" rx="3.5" fill="#7D9093" fill-opacity="0.26"/>
4046
+ </svg>
4047
+ <div>
4048
+ <button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
4049
+ Continue to Allow
4050
+ </button>
4051
+ </div>
4052
+ `;
4053
+ const css$1 = `
4054
+ .mobile-wallet-adapter-embedded-modal-close {
4055
+ display: none;
4056
+ }
4057
+ .mobile-wallet-adapter-embedded-modal-content {
4058
+ text-align: center;
4059
+ }
4060
+ .mobile-wallet-adapter-embedded-modal-title {
4061
+ margin: 18px 100px auto 100px;
4062
+ color: #000000;
4063
+ font-size: 2.75em;
4064
+ font-weight: 600;
4065
+ }
4066
+ .mobile-wallet-adapter-embedded-modal-subtitle {
4067
+ margin: 20px 60px 40px 60px;
4068
+ color: #7D9093;
4069
+ font-size: 1.25em;
4070
+ font-weight: 400;
4071
+ }
4072
+ .mobile-wallet-adapter-embedded-modal-permission-prompt-mock {
4073
+ width: 90%;
4074
+ height: auto;
4075
+ margin: 0 auto 30px auto;
4076
+ display: block;
4077
+ }
4078
+ .mobile-wallet-adapter-embedded-modal-launch-action {
4079
+ display: block;
4080
+ width: 100%;
4081
+ height: 56px;
4082
+ font-size: 1.25em;
4083
+ background: #000000;
4084
+ color: #FFFFFF;
4085
+ border-radius: 18px;
4086
+ }
4087
+ /* Smaller screens */
4088
+ @media all and (max-width: 600px) {
4089
+ .mobile-wallet-adapter-embedded-modal-title {
4090
+ font-size: 1.5em;
4091
+ margin-right: 12px;
4092
+ margin-left: 12px;
4604
4093
  }
4605
- /** @deprecated */
4606
- stopPropagation() {
4607
- throw new Error('stopPropagation cannot be called');
4094
+ .mobile-wallet-adapter-embedded-modal-subtitle {
4095
+ margin-right: 12px;
4096
+ margin-left: 12px;
4608
4097
  }
4609
4098
  }
4610
- _RegisterWalletEvent_detail = new WeakMap();
4611
-
4099
+ `;
4100
+ //#endregion
4101
+ //#region src/getIsSupported.ts
4612
4102
  function getIsLocalAssociationSupported() {
4613
- return (typeof window !== 'undefined' &&
4614
- window.isSecureContext &&
4615
- typeof document !== 'undefined' &&
4616
- /android/i.test(navigator.userAgent));
4103
+ return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
4617
4104
  }
4618
4105
  function getIsRemoteAssociationSupported() {
4619
- return (typeof window !== 'undefined' &&
4620
- window.isSecureContext &&
4621
- typeof document !== 'undefined' &&
4622
- !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
4106
+ return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
4623
4107
  }
4624
- // Source: https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/getEnvironment.ts#L14
4625
- // This is the same implementation that gated MWA in the Anza wallet-adapter-react library.
4626
4108
  function isWebView(userAgentString) {
4627
- return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
4109
+ return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
4628
4110
  }
4629
-
4630
- function registerMwa(config) {
4631
- if (typeof window === 'undefined') {
4632
- console.warn(`MWA not registered: no window object`);
4633
- return;
4634
- }
4635
- if (!window.isSecureContext) {
4636
- console.warn(`MWA not registered: secure context required (https)`);
4637
- return;
4638
- }
4639
- // Local association technically is possible in a webview, but we prevent registration
4640
- // by default because it usually fails in the most common cases (e.g wallet browsers).
4641
- if (getIsLocalAssociationSupported() && !isWebView(navigator.userAgent)) {
4642
- registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
4643
- }
4644
- else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== undefined) {
4645
- registerWallet(new RemoteSolanaMobileWalletAdapterWallet(Object.assign(Object.assign({}, config), { remoteHostAuthority: config.remoteHostAuthority })));
4646
- }
4647
- else ;
4111
+ function isSolanaMobileWebShell(userAgentString) {
4112
+ return userAgentString.includes("Solana Mobile Web Shell");
4648
4113
  }
4649
-
4650
- const WALLET_NOT_FOUND_ERROR_MESSAGE = 'To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.';
4651
- 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.';
4652
- class ErrorModal extends EmbeddedModal {
4653
- constructor() {
4654
- super(...arguments);
4655
- this.contentStyles = css;
4656
- this.contentHtml = ErrorDialogHtml;
4657
- }
4658
- initWithError(error) {
4659
- super.init();
4660
- this.populateError(error);
4661
- }
4662
- populateError(error) {
4663
- var _a, _b;
4664
- const errorMessageElement = (_a = this.dom) === null || _a === void 0 ? void 0 : _a.getElementById('mobile-wallet-adapter-error-message');
4665
- const actionBtn = (_b = this.dom) === null || _b === void 0 ? void 0 : _b.getElementById('mobile-wallet-adapter-error-action');
4666
- if (errorMessageElement) {
4667
- if (error.name === 'SolanaMobileWalletAdapterError') {
4668
- switch (error.code) {
4669
- case 'ERROR_WALLET_NOT_FOUND':
4670
- errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
4671
- if (actionBtn)
4672
- actionBtn.addEventListener('click', () => {
4673
- window.location.href = 'https://solanamobile.com/wallets';
4674
- });
4675
- return;
4676
- case 'ERROR_BROWSER_NOT_SUPPORTED':
4677
- errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
4678
- if (actionBtn)
4679
- actionBtn.style.display = 'none';
4680
- return;
4681
- }
4682
- }
4683
- errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
4684
- }
4685
- else {
4686
- console.log('Failed to locate error dialog element');
4687
- }
4688
- }
4114
+ function getIsPwaLaunchedAsApp() {
4115
+ const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
4116
+ if (typeof window == "undefined") return isAndroidTwa;
4117
+ const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
4118
+ const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
4119
+ const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
4120
+ return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
4121
+ }
4122
+ async function checkLocalNetworkAccessPermission() {
4123
+ if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
4124
+ try {
4125
+ const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
4126
+ if (lnaPermission.state === "granted") return;
4127
+ else if (lnaPermission.state === "denied") {
4128
+ const modal = new LoopbackPermissionBlockedModal();
4129
+ modal.init();
4130
+ modal.open();
4131
+ throw new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
4132
+ } else if (lnaPermission.state === "prompt") {
4133
+ const modal = new LoopbackPermissionModal();
4134
+ if (await new Promise((resolve, reject) => {
4135
+ modal.addEventListener("close", (event) => {
4136
+ if (event) reject(new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
4137
+ });
4138
+ lnaPermission.onchange = () => {
4139
+ lnaPermission.onchange = null;
4140
+ resolve(lnaPermission.state);
4141
+ };
4142
+ modal.init();
4143
+ modal.open();
4144
+ }) === "granted") {
4145
+ const modal = new LocalConnectionModal();
4146
+ await new Promise((resolve, reject) => {
4147
+ modal.addEventListener("close", (event) => {
4148
+ if (event) reject(new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
4149
+ });
4150
+ modal.initWithCallback(async () => {
4151
+ resolve(true);
4152
+ });
4153
+ modal.open();
4154
+ });
4155
+ return;
4156
+ } else return await checkLocalNetworkAccessPermission();
4157
+ }
4158
+ throw new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
4159
+ } catch (e) {
4160
+ if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
4161
+ if (e instanceof index_browser.SolanaMobileWalletAdapterError) throw e;
4162
+ throw new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
4163
+ }
4164
+ }
4165
+ //#endregion
4166
+ //#region src/icon.ts
4167
+ const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
4168
+ //#endregion
4169
+ //#region src/wallet.ts
4170
+ const SolanaMobileWalletAdapterWalletName = "Mobile Wallet Adapter";
4171
+ const SolanaMobileWalletAdapterRemoteWalletName = "Remote Mobile Wallet Adapter";
4172
+ const SIGNATURE_LENGTH_IN_BYTES = 64;
4173
+ const DEFAULT_FEATURES = [
4174
+ SolanaSignAndSendTransaction,
4175
+ SolanaSignTransaction,
4176
+ SolanaSignMessage,
4177
+ SolanaSignIn
4178
+ ];
4179
+ const WALLET_ASSOCIATION_TIMEOUT = 3e4;
4180
+ function getErrorMessage(error) {
4181
+ return error instanceof Error ? error.message : "Unknown error";
4182
+ }
4183
+ var LocalSolanaMobileWalletAdapterWallet = class {
4184
+ #listeners = {};
4185
+ #version = "1.0.0";
4186
+ #name = SolanaMobileWalletAdapterWalletName;
4187
+ #url = "https://solanamobile.com/wallets";
4188
+ #icon = icon;
4189
+ #appIdentity;
4190
+ #authorization;
4191
+ #authorizationCache;
4192
+ #connecting = false;
4193
+ /**
4194
+ * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4195
+ * increment this and use it to make sure that `transact` calls from the previous
4196
+ * 'generation' don't continue to do work and throw exceptions.
4197
+ */
4198
+ #connectionGeneration = 0;
4199
+ #chains = [];
4200
+ #chainSelector;
4201
+ #optionalFeatures;
4202
+ #onWalletNotFound;
4203
+ get version() {
4204
+ return this.#version;
4205
+ }
4206
+ get name() {
4207
+ return this.#name;
4208
+ }
4209
+ get url() {
4210
+ return this.#url;
4211
+ }
4212
+ get icon() {
4213
+ return this.#icon;
4214
+ }
4215
+ get chains() {
4216
+ return this.#chains;
4217
+ }
4218
+ get features() {
4219
+ return {
4220
+ [StandardConnect]: {
4221
+ version: "1.0.0",
4222
+ connect: this.#connect
4223
+ },
4224
+ [StandardDisconnect]: {
4225
+ version: "1.0.0",
4226
+ disconnect: this.#disconnect
4227
+ },
4228
+ [StandardEvents]: {
4229
+ version: "1.0.0",
4230
+ on: this.#on
4231
+ },
4232
+ [SolanaSignMessage]: {
4233
+ version: "1.0.0",
4234
+ signMessage: this.#signMessage
4235
+ },
4236
+ [SolanaSignIn]: {
4237
+ version: "1.0.0",
4238
+ signIn: this.#signIn
4239
+ },
4240
+ ...this.#optionalFeatures
4241
+ };
4242
+ }
4243
+ get accounts() {
4244
+ return this.#authorization?.accounts ?? [];
4245
+ }
4246
+ constructor(config) {
4247
+ this.#authorizationCache = config.authorizationCache;
4248
+ this.#appIdentity = config.appIdentity;
4249
+ this.#chains = config.chains;
4250
+ this.#chainSelector = config.chainSelector;
4251
+ this.#onWalletNotFound = config.onWalletNotFound;
4252
+ this.#optionalFeatures = {
4253
+ [SolanaSignAndSendTransaction]: {
4254
+ version: "1.0.0",
4255
+ supportedTransactionVersions: ["legacy", 0],
4256
+ signAndSendTransaction: this.#signAndSendTransaction
4257
+ },
4258
+ [SolanaSignTransaction]: {
4259
+ version: "1.0.0",
4260
+ supportedTransactionVersions: ["legacy", 0],
4261
+ signTransaction: this.#signTransaction
4262
+ }
4263
+ };
4264
+ }
4265
+ get connected() {
4266
+ return !!this.#authorization;
4267
+ }
4268
+ get isAuthorized() {
4269
+ return !!this.#authorization;
4270
+ }
4271
+ get currentAuthorization() {
4272
+ return this.#authorization;
4273
+ }
4274
+ get cachedAuthorizationResult() {
4275
+ return this.#authorizationCache.get();
4276
+ }
4277
+ #on = (event, listener) => {
4278
+ this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
4279
+ return () => this.#off(event, listener);
4280
+ };
4281
+ #emit(event, ...args) {
4282
+ this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
4283
+ }
4284
+ #off(event, listener) {
4285
+ this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
4286
+ }
4287
+ #connect = async ({ silent } = {}) => {
4288
+ if (this.#connecting || this.connected) return { accounts: this.accounts };
4289
+ this.#connecting = true;
4290
+ try {
4291
+ if (silent) {
4292
+ const cachedAuthorization = await this.#authorizationCache.get();
4293
+ if (cachedAuthorization) {
4294
+ await this.#handleWalletCapabilitiesResult(cachedAuthorization.capabilities);
4295
+ await this.#handleAuthorizationResult(cachedAuthorization);
4296
+ } else return { accounts: this.accounts };
4297
+ } else await this.#performAuthorization();
4298
+ } catch (e) {
4299
+ throw new Error(getErrorMessage(e), { cause: e });
4300
+ } finally {
4301
+ this.#connecting = false;
4302
+ }
4303
+ return { accounts: this.accounts };
4304
+ };
4305
+ #performAuthorization = async (signInPayload) => {
4306
+ try {
4307
+ const cachedAuthorizationResult = await this.#authorizationCache.get();
4308
+ if (cachedAuthorizationResult) {
4309
+ this.#handleAuthorizationResult(cachedAuthorizationResult);
4310
+ return cachedAuthorizationResult;
4311
+ }
4312
+ const selectedChain = await this.#chainSelector.select(this.#chains);
4313
+ return await this.#transact(async (wallet) => {
4314
+ const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
4315
+ chain: selectedChain,
4316
+ identity: this.#appIdentity,
4317
+ sign_in_payload: signInPayload
4318
+ })]);
4319
+ const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4320
+ const authorization = {
4321
+ ...mwaAuthorizationResult,
4322
+ accounts,
4323
+ chain: selectedChain,
4324
+ capabilities
4325
+ };
4326
+ Promise.all([
4327
+ this.#handleWalletCapabilitiesResult(capabilities),
4328
+ this.#authorizationCache.set(authorization),
4329
+ this.#handleAuthorizationResult(authorization)
4330
+ ]);
4331
+ return authorization;
4332
+ });
4333
+ } catch (e) {
4334
+ throw new Error(getErrorMessage(e), { cause: e });
4335
+ }
4336
+ };
4337
+ #handleAuthorizationResult = async (authorization) => {
4338
+ const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4339
+ this.#authorization = authorization;
4340
+ if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
4341
+ };
4342
+ #handleWalletCapabilitiesResult = async (capabilities) => {
4343
+ const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
4344
+ const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
4345
+ const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
4346
+ this.#optionalFeatures = {
4347
+ ...(supportsSignAndSendTransaction || !supportsSignAndSendTransaction && !supportsSignTransaction) && { [SolanaSignAndSendTransaction]: {
4348
+ version: "1.0.0",
4349
+ supportedTransactionVersions: ["legacy", 0],
4350
+ signAndSendTransaction: this.#signAndSendTransaction
4351
+ } },
4352
+ ...supportsSignTransaction && { [SolanaSignTransaction]: {
4353
+ version: "1.0.0",
4354
+ supportedTransactionVersions: ["legacy", 0],
4355
+ signTransaction: this.#signTransaction
4356
+ } }
4357
+ };
4358
+ if (didCapabilitiesChange) this.#emit("change", { features: this.features });
4359
+ };
4360
+ #performReauthorization = async (wallet, authToken, chain) => {
4361
+ try {
4362
+ const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
4363
+ auth_token: authToken,
4364
+ identity: this.#appIdentity,
4365
+ chain
4366
+ })]);
4367
+ const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4368
+ const authorization = {
4369
+ ...mwaAuthorizationResult,
4370
+ accounts,
4371
+ chain,
4372
+ capabilities
4373
+ };
4374
+ Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
4375
+ } catch (e) {
4376
+ this.#disconnect();
4377
+ throw new Error(getErrorMessage(e), { cause: e });
4378
+ }
4379
+ };
4380
+ #disconnect = async () => {
4381
+ this.#authorizationCache.clear();
4382
+ this.#connecting = false;
4383
+ this.#connectionGeneration++;
4384
+ this.#authorization = void 0;
4385
+ this.#emit("change", { accounts: this.accounts });
4386
+ };
4387
+ #transact = async (callback) => {
4388
+ const walletUriBase = this.#authorization?.wallet_uri_base;
4389
+ const config = walletUriBase ? { baseUri: walletUriBase } : void 0;
4390
+ const currentConnectionGeneration = this.#connectionGeneration;
4391
+ const loadingSpinner = new EmbeddedLoadingSpinner();
4392
+ try {
4393
+ let associating = true;
4394
+ let timeout = void 0;
4395
+ const result = await Promise.race([checkLocalNetworkAccessPermission().then(async () => {
4396
+ loadingSpinner.init();
4397
+ const { wallet, close } = await index_browser.startScenario(config);
4398
+ associating = false;
4399
+ loadingSpinner.addEventListener("close", (event) => {
4400
+ if (event) close();
4401
+ });
4402
+ loadingSpinner.open();
4403
+ const result = await callback(await wallet);
4404
+ loadingSpinner.close();
4405
+ close();
4406
+ return result;
4407
+ }), new Promise((_, reject) => {
4408
+ timeout = setTimeout(() => {
4409
+ if (associating) reject(new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
4410
+ }, WALLET_ASSOCIATION_TIMEOUT);
4411
+ })]);
4412
+ clearTimeout(timeout);
4413
+ return result;
4414
+ } catch (e) {
4415
+ loadingSpinner.close();
4416
+ if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
4417
+ if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
4418
+ throw e;
4419
+ }
4420
+ };
4421
+ #assertIsAuthorized = () => {
4422
+ if (!this.#authorization) throw new Error("Wallet not connected");
4423
+ return {
4424
+ authToken: this.#authorization.auth_token,
4425
+ chain: this.#authorization.chain
4426
+ };
4427
+ };
4428
+ #accountsToWalletStandardAccounts = (accounts) => {
4429
+ return accounts.map((account) => {
4430
+ const publicKey = toUint8Array(account.address);
4431
+ return {
4432
+ address: index.base58.encode(publicKey),
4433
+ publicKey,
4434
+ label: account.label,
4435
+ icon: account.icon,
4436
+ chains: account.chains ?? this.#chains,
4437
+ features: account.features ?? DEFAULT_FEATURES
4438
+ };
4439
+ });
4440
+ };
4441
+ #performSignTransactions = async (transactions) => {
4442
+ const { authToken, chain } = this.#assertIsAuthorized();
4443
+ try {
4444
+ const base64Transactions = transactions.map((tx) => {
4445
+ return fromUint8Array(tx);
4446
+ });
4447
+ return await this.#transact(async (wallet) => {
4448
+ await this.#performReauthorization(wallet, authToken, chain);
4449
+ return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(toUint8Array);
4450
+ });
4451
+ } catch (e) {
4452
+ throw new Error(getErrorMessage(e), { cause: e });
4453
+ }
4454
+ };
4455
+ #performSignAndSendTransaction = async (transaction, options) => {
4456
+ const { authToken, chain } = this.#assertIsAuthorized();
4457
+ try {
4458
+ return await this.#transact(async (wallet) => {
4459
+ const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
4460
+ if (capabilities.supports_sign_and_send_transactions) {
4461
+ const base64Transaction = fromUint8Array(transaction);
4462
+ return (await wallet.signAndSendTransactions({
4463
+ ...options,
4464
+ payloads: [base64Transaction]
4465
+ })).signatures.map(toUint8Array)[0];
4466
+ } else throw new Error("connected wallet does not support signAndSendTransaction");
4467
+ });
4468
+ } catch (e) {
4469
+ throw new Error(getErrorMessage(e), { cause: e });
4470
+ }
4471
+ };
4472
+ #signAndSendTransaction = async (...inputs) => {
4473
+ const outputs = [];
4474
+ for (const input of inputs) {
4475
+ const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
4476
+ outputs.push({ signature });
4477
+ }
4478
+ return outputs;
4479
+ };
4480
+ #signTransaction = async (...inputs) => {
4481
+ return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
4482
+ return { signedTransaction };
4483
+ });
4484
+ };
4485
+ #signMessage = async (...inputs) => {
4486
+ const { authToken, chain } = this.#assertIsAuthorized();
4487
+ const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
4488
+ const messages = inputs.map(({ message }) => fromUint8Array(message));
4489
+ try {
4490
+ return await this.#transact(async (wallet) => {
4491
+ await this.#performReauthorization(wallet, authToken, chain);
4492
+ return (await wallet.signMessages({
4493
+ addresses,
4494
+ payloads: messages
4495
+ })).signed_payloads.map(toUint8Array).map((signedMessage) => {
4496
+ return {
4497
+ signedMessage,
4498
+ signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
4499
+ };
4500
+ });
4501
+ });
4502
+ } catch (e) {
4503
+ throw new Error(getErrorMessage(e), { cause: e });
4504
+ }
4505
+ };
4506
+ #signIn = async (...inputs) => {
4507
+ const outputs = [];
4508
+ if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
4509
+ else return [await this.#performSignIn(inputs[0])];
4510
+ return outputs;
4511
+ };
4512
+ #performSignIn = async (input) => {
4513
+ this.#connecting = true;
4514
+ try {
4515
+ const authorizationResult = await this.#performAuthorization({
4516
+ ...input,
4517
+ domain: input?.domain ?? window.location.host
4518
+ });
4519
+ if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
4520
+ const signedInAddress = authorizationResult.sign_in_result.address;
4521
+ const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
4522
+ return {
4523
+ account: {
4524
+ ...signedInAccount ?? { address: index.base58.encode(toUint8Array(signedInAddress)) },
4525
+ publicKey: toUint8Array(signedInAddress),
4526
+ chains: signedInAccount?.chains ?? this.#chains,
4527
+ features: signedInAccount?.features ?? authorizationResult.capabilities.features
4528
+ },
4529
+ signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4530
+ signature: toUint8Array(authorizationResult.sign_in_result.signature)
4531
+ };
4532
+ } catch (e) {
4533
+ throw new Error(getErrorMessage(e), { cause: e });
4534
+ } finally {
4535
+ this.#connecting = false;
4536
+ }
4537
+ };
4538
+ };
4539
+ var RemoteSolanaMobileWalletAdapterWallet = class {
4540
+ #listeners = {};
4541
+ #version = "1.0.0";
4542
+ #name = SolanaMobileWalletAdapterRemoteWalletName;
4543
+ #url = "https://solanamobile.com/wallets";
4544
+ #icon = icon;
4545
+ #appIdentity;
4546
+ #authorization;
4547
+ #authorizationCache;
4548
+ #connecting = false;
4549
+ /**
4550
+ * Every time the connection is recycled in some way (eg. `disconnect()` is called)
4551
+ * increment this and use it to make sure that `transact` calls from the previous
4552
+ * 'generation' don't continue to do work and throw exceptions.
4553
+ */
4554
+ #connectionGeneration = 0;
4555
+ #chains = [];
4556
+ #chainSelector;
4557
+ #optionalFeatures;
4558
+ #onWalletNotFound;
4559
+ #hostAuthority;
4560
+ #session;
4561
+ get version() {
4562
+ return this.#version;
4563
+ }
4564
+ get name() {
4565
+ return this.#name;
4566
+ }
4567
+ get url() {
4568
+ return this.#url;
4569
+ }
4570
+ get icon() {
4571
+ return this.#icon;
4572
+ }
4573
+ get chains() {
4574
+ return this.#chains;
4575
+ }
4576
+ get features() {
4577
+ return {
4578
+ [StandardConnect]: {
4579
+ version: "1.0.0",
4580
+ connect: this.#connect
4581
+ },
4582
+ [StandardDisconnect]: {
4583
+ version: "1.0.0",
4584
+ disconnect: this.#disconnect
4585
+ },
4586
+ [StandardEvents]: {
4587
+ version: "1.0.0",
4588
+ on: this.#on
4589
+ },
4590
+ [SolanaSignMessage]: {
4591
+ version: "1.0.0",
4592
+ signMessage: this.#signMessage
4593
+ },
4594
+ [SolanaSignIn]: {
4595
+ version: "1.0.0",
4596
+ signIn: this.#signIn
4597
+ },
4598
+ ...this.#optionalFeatures
4599
+ };
4600
+ }
4601
+ get accounts() {
4602
+ return this.#authorization?.accounts ?? [];
4603
+ }
4604
+ constructor(config) {
4605
+ this.#authorizationCache = config.authorizationCache;
4606
+ this.#appIdentity = config.appIdentity;
4607
+ this.#chains = config.chains;
4608
+ this.#chainSelector = config.chainSelector;
4609
+ this.#hostAuthority = config.remoteHostAuthority;
4610
+ this.#onWalletNotFound = config.onWalletNotFound;
4611
+ this.#optionalFeatures = {
4612
+ [SolanaSignAndSendTransaction]: {
4613
+ version: "1.0.0",
4614
+ supportedTransactionVersions: ["legacy", 0],
4615
+ signAndSendTransaction: this.#signAndSendTransaction
4616
+ },
4617
+ [SolanaSignTransaction]: {
4618
+ version: "1.0.0",
4619
+ supportedTransactionVersions: ["legacy", 0],
4620
+ signTransaction: this.#signTransaction
4621
+ }
4622
+ };
4623
+ }
4624
+ get connected() {
4625
+ return !!this.#session && !!this.#authorization;
4626
+ }
4627
+ get isAuthorized() {
4628
+ return !!this.#authorization;
4629
+ }
4630
+ get currentAuthorization() {
4631
+ return this.#authorization;
4632
+ }
4633
+ get cachedAuthorizationResult() {
4634
+ return this.#authorizationCache.get();
4635
+ }
4636
+ #on = (event, listener) => {
4637
+ this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
4638
+ return () => this.#off(event, listener);
4639
+ };
4640
+ #emit(event, ...args) {
4641
+ this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
4642
+ }
4643
+ #off(event, listener) {
4644
+ this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
4645
+ }
4646
+ #connect = async (_input = {}) => {
4647
+ if (this.#connecting || this.connected) return { accounts: this.accounts };
4648
+ this.#connecting = true;
4649
+ try {
4650
+ await this.#performAuthorization();
4651
+ } catch (e) {
4652
+ throw new Error(getErrorMessage(e), { cause: e });
4653
+ } finally {
4654
+ this.#connecting = false;
4655
+ }
4656
+ return { accounts: this.accounts };
4657
+ };
4658
+ #performAuthorization = async (signInPayload) => {
4659
+ try {
4660
+ const cachedAuthorizationResult = await this.#authorizationCache.get();
4661
+ if (cachedAuthorizationResult) {
4662
+ this.#handleAuthorizationResult(cachedAuthorizationResult);
4663
+ return cachedAuthorizationResult;
4664
+ }
4665
+ if (this.#session) this.#session = void 0;
4666
+ const selectedChain = await this.#chainSelector.select(this.#chains);
4667
+ return await this.#transact(async (wallet) => {
4668
+ const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
4669
+ chain: selectedChain,
4670
+ identity: this.#appIdentity,
4671
+ sign_in_payload: signInPayload
4672
+ })]);
4673
+ const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4674
+ const authorizationResult = {
4675
+ ...mwaAuthorizationResult,
4676
+ accounts,
4677
+ chain: selectedChain,
4678
+ capabilities
4679
+ };
4680
+ Promise.all([
4681
+ this.#handleWalletCapabilitiesResult(capabilities),
4682
+ this.#authorizationCache.set(authorizationResult),
4683
+ this.#handleAuthorizationResult(authorizationResult)
4684
+ ]);
4685
+ return authorizationResult;
4686
+ });
4687
+ } catch (e) {
4688
+ throw new Error(getErrorMessage(e), { cause: e });
4689
+ }
4690
+ };
4691
+ #handleAuthorizationResult = async (authorization) => {
4692
+ const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
4693
+ this.#authorization = authorization;
4694
+ if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
4695
+ };
4696
+ #handleWalletCapabilitiesResult = async (capabilities) => {
4697
+ const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
4698
+ const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions || capabilities.features.includes("solana:signAndSendTransaction");
4699
+ const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
4700
+ this.#optionalFeatures = {
4701
+ ...supportsSignAndSendTransaction && { [SolanaSignAndSendTransaction]: {
4702
+ version: "1.0.0",
4703
+ supportedTransactionVersions: capabilities.supported_transaction_versions,
4704
+ signAndSendTransaction: this.#signAndSendTransaction
4705
+ } },
4706
+ ...supportsSignTransaction && { [SolanaSignTransaction]: {
4707
+ version: "1.0.0",
4708
+ supportedTransactionVersions: capabilities.supported_transaction_versions,
4709
+ signTransaction: this.#signTransaction
4710
+ } }
4711
+ };
4712
+ if (didCapabilitiesChange) this.#emit("change", { features: this.features });
4713
+ };
4714
+ #performReauthorization = async (wallet, authToken, chain) => {
4715
+ try {
4716
+ const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
4717
+ auth_token: authToken,
4718
+ identity: this.#appIdentity,
4719
+ chain
4720
+ })]);
4721
+ const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
4722
+ const authorization = {
4723
+ ...mwaAuthorizationResult,
4724
+ accounts,
4725
+ chain,
4726
+ capabilities
4727
+ };
4728
+ Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
4729
+ } catch (e) {
4730
+ this.#disconnect();
4731
+ throw new Error(getErrorMessage(e), { cause: e });
4732
+ }
4733
+ };
4734
+ #disconnect = async () => {
4735
+ this.#session?.close();
4736
+ this.#authorizationCache.clear();
4737
+ this.#connecting = false;
4738
+ this.#connectionGeneration++;
4739
+ this.#authorization = void 0;
4740
+ this.#session = void 0;
4741
+ this.#emit("change", { accounts: this.accounts });
4742
+ };
4743
+ #transact = async (callback) => {
4744
+ const walletUriBase = this.#authorization?.wallet_uri_base;
4745
+ const remoteConfig = {
4746
+ ...walletUriBase ? { baseUri: walletUriBase } : void 0,
4747
+ remoteHostAuthority: this.#hostAuthority
4748
+ };
4749
+ const currentConnectionGeneration = this.#connectionGeneration;
4750
+ const modal = new RemoteConnectionModal();
4751
+ if (this.#session) return callback(this.#session.wallet);
4752
+ try {
4753
+ modal.init();
4754
+ modal.open();
4755
+ const { associationUrl, close, wallet } = await index_browser.startRemoteScenario(remoteConfig);
4756
+ const removeCloseListener = modal.addEventListener("close", (event) => {
4757
+ if (event) close();
4758
+ });
4759
+ modal.populateQRCode(associationUrl.toString());
4760
+ this.#session = {
4761
+ close,
4762
+ wallet: await wallet
4763
+ };
4764
+ removeCloseListener();
4765
+ modal.close();
4766
+ return await callback(this.#session.wallet);
4767
+ } catch (e) {
4768
+ modal.close();
4769
+ if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
4770
+ if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
4771
+ throw e;
4772
+ }
4773
+ };
4774
+ #assertIsAuthorized = () => {
4775
+ if (!this.#authorization) throw new Error("Wallet not connected");
4776
+ return {
4777
+ authToken: this.#authorization.auth_token,
4778
+ chain: this.#authorization.chain
4779
+ };
4780
+ };
4781
+ #accountsToWalletStandardAccounts = (accounts) => {
4782
+ return accounts.map((account) => {
4783
+ const publicKey = toUint8Array(account.address);
4784
+ return {
4785
+ address: index.base58.encode(publicKey),
4786
+ publicKey,
4787
+ label: account.label,
4788
+ icon: account.icon,
4789
+ chains: account.chains ?? this.#chains,
4790
+ features: account.features ?? DEFAULT_FEATURES
4791
+ };
4792
+ });
4793
+ };
4794
+ #performSignTransactions = async (transactions) => {
4795
+ const { authToken, chain } = this.#assertIsAuthorized();
4796
+ try {
4797
+ return await this.#transact(async (wallet) => {
4798
+ await this.#performReauthorization(wallet, authToken, chain);
4799
+ return (await wallet.signTransactions({ payloads: transactions.map(fromUint8Array) })).signed_payloads.map(toUint8Array);
4800
+ });
4801
+ } catch (e) {
4802
+ throw new Error(getErrorMessage(e), { cause: e });
4803
+ }
4804
+ };
4805
+ #performSignAndSendTransaction = async (transaction, options) => {
4806
+ const { authToken, chain } = this.#assertIsAuthorized();
4807
+ try {
4808
+ return await this.#transact(async (wallet) => {
4809
+ const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
4810
+ if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
4811
+ ...options,
4812
+ payloads: [fromUint8Array(transaction)]
4813
+ })).signatures.map(toUint8Array)[0];
4814
+ else throw new Error("connected wallet does not support signAndSendTransaction");
4815
+ });
4816
+ } catch (e) {
4817
+ throw new Error(getErrorMessage(e), { cause: e });
4818
+ }
4819
+ };
4820
+ #signAndSendTransaction = async (...inputs) => {
4821
+ const outputs = [];
4822
+ for (const input of inputs) {
4823
+ const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
4824
+ outputs.push({ signature });
4825
+ }
4826
+ return outputs;
4827
+ };
4828
+ #signTransaction = async (...inputs) => {
4829
+ return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
4830
+ return { signedTransaction };
4831
+ });
4832
+ };
4833
+ #signMessage = async (...inputs) => {
4834
+ const { authToken, chain } = this.#assertIsAuthorized();
4835
+ const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
4836
+ const messages = inputs.map(({ message }) => fromUint8Array(message));
4837
+ try {
4838
+ return await this.#transact(async (wallet) => {
4839
+ await this.#performReauthorization(wallet, authToken, chain);
4840
+ return (await wallet.signMessages({
4841
+ addresses,
4842
+ payloads: messages
4843
+ })).signed_payloads.map(toUint8Array).map((signedMessage) => {
4844
+ return {
4845
+ signedMessage,
4846
+ signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
4847
+ };
4848
+ });
4849
+ });
4850
+ } catch (e) {
4851
+ throw new Error(getErrorMessage(e), { cause: e });
4852
+ }
4853
+ };
4854
+ #signIn = async (...inputs) => {
4855
+ const outputs = [];
4856
+ if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
4857
+ else return [await this.#performSignIn(inputs[0])];
4858
+ return outputs;
4859
+ };
4860
+ #performSignIn = async (input) => {
4861
+ this.#connecting = true;
4862
+ try {
4863
+ const authorizationResult = await this.#performAuthorization({
4864
+ ...input,
4865
+ domain: input?.domain ?? window.location.host
4866
+ });
4867
+ if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
4868
+ const signedInAddress = authorizationResult.sign_in_result.address;
4869
+ const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
4870
+ return {
4871
+ account: {
4872
+ ...signedInAccount ?? { address: index.base58.encode(toUint8Array(signedInAddress)) },
4873
+ publicKey: toUint8Array(signedInAddress),
4874
+ chains: signedInAccount?.chains ?? this.#chains,
4875
+ features: signedInAccount?.features ?? authorizationResult.capabilities.features
4876
+ },
4877
+ signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
4878
+ signature: toUint8Array(authorizationResult.sign_in_result.signature)
4879
+ };
4880
+ } catch (e) {
4881
+ throw new Error(getErrorMessage(e), { cause: e });
4882
+ } finally {
4883
+ this.#connecting = false;
4884
+ }
4885
+ };
4886
+ };
4887
+ //#endregion
4888
+ //#region src/initialize.ts
4889
+ function registerMwa(config) {
4890
+ if (typeof window === "undefined") {
4891
+ console.warn(`MWA not registered: no window object`);
4892
+ return;
4893
+ }
4894
+ if (!window.isSecureContext) {
4895
+ console.warn(`MWA not registered: secure context required (https)`);
4896
+ return;
4897
+ }
4898
+ const userAgent = navigator.userAgent;
4899
+ if (getIsLocalAssociationSupported() && (!isWebView(userAgent) || isSolanaMobileWebShell(userAgent))) registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
4900
+ else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== void 0) registerWallet(new RemoteSolanaMobileWalletAdapterWallet({
4901
+ ...config,
4902
+ remoteHostAuthority: config.remoteHostAuthority
4903
+ }));
4689
4904
  }
4905
+ //#endregion
4906
+ //#region src/embedded-modal/errorModal.ts
4907
+ const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
4908
+ 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.";
4909
+ var ErrorModal = class extends EmbeddedModal {
4910
+ contentStyles = css;
4911
+ contentHtml = ErrorDialogHtml;
4912
+ initWithError(error) {
4913
+ super.init();
4914
+ this.populateError(error);
4915
+ }
4916
+ populateError(error) {
4917
+ const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
4918
+ const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
4919
+ if (errorMessageElement) {
4920
+ if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
4921
+ case "ERROR_WALLET_NOT_FOUND":
4922
+ errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
4923
+ if (actionBtn) actionBtn.addEventListener("click", () => {
4924
+ window.location.href = "https://solanamobile.com/wallets";
4925
+ });
4926
+ return;
4927
+ case "ERROR_BROWSER_NOT_SUPPORTED":
4928
+ errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
4929
+ if (actionBtn) actionBtn.style.display = "none";
4930
+ return;
4931
+ }
4932
+ errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
4933
+ } else console.log("Failed to locate error dialog element");
4934
+ }
4935
+ };
4690
4936
  const ErrorDialogHtml = `
4691
4937
  <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>
4692
4938
  <div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
@@ -4746,122 +4992,79 @@ const css = `
4746
4992
  }
4747
4993
  }
4748
4994
  `;
4749
-
4750
- function defaultErrorModalWalletNotFoundHandler() {
4751
- return __awaiter(this, void 0, void 0, function* () {
4752
- if (typeof window !== 'undefined') {
4753
- const userAgent = window.navigator.userAgent.toLowerCase();
4754
- const errorDialog = new ErrorModal();
4755
- if (userAgent.includes('wv')) { // Android WebView
4756
- // MWA is not supported in this browser so we inform the user
4757
- // errorDialog.initWithError(
4758
- // new SolanaMobileWalletAdapterError(
4759
- // SolanaMobileWalletAdapterErrorCode.ERROR_BROWSER_NOT_SUPPORTED,
4760
- // ''
4761
- // )
4762
- // );
4763
- // TODO: investigate why instantiating a new SolanaMobileWalletAdapterError here breaks treeshaking
4764
- errorDialog.initWithError({
4765
- name: 'SolanaMobileWalletAdapterError',
4766
- code: 'ERROR_BROWSER_NOT_SUPPORTED',
4767
- message: ''
4768
- });
4769
- }
4770
- else { // Browser, user does not have a wallet installed.
4771
- // errorDialog.initWithError(
4772
- // new SolanaMobileWalletAdapterError(
4773
- // SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND,
4774
- // ''
4775
- // )
4776
- // );
4777
- // TODO: investigate why instantiating a new SolanaMobileWalletAdapterError here breaks treeshaking
4778
- errorDialog.initWithError({
4779
- name: 'SolanaMobileWalletAdapterError',
4780
- code: 'ERROR_WALLET_NOT_FOUND',
4781
- message: ''
4782
- });
4783
- }
4784
- errorDialog.open();
4785
- }
4786
- });
4995
+ //#endregion
4996
+ //#region src/createDefaultWalletNotFoundHandler.ts
4997
+ async function defaultErrorModalWalletNotFoundHandler() {
4998
+ if (typeof window !== "undefined") {
4999
+ const userAgent = window.navigator.userAgent.toLowerCase();
5000
+ const errorDialog = new ErrorModal();
5001
+ if (userAgent.includes("wv")) errorDialog.initWithError({
5002
+ name: "SolanaMobileWalletAdapterError",
5003
+ code: "ERROR_BROWSER_NOT_SUPPORTED",
5004
+ message: ""
5005
+ });
5006
+ else errorDialog.initWithError({
5007
+ name: "SolanaMobileWalletAdapterError",
5008
+ code: "ERROR_WALLET_NOT_FOUND",
5009
+ message: ""
5010
+ });
5011
+ errorDialog.open();
5012
+ }
4787
5013
  }
4788
5014
  function createDefaultWalletNotFoundHandler() {
4789
- return () => __awaiter(this, void 0, void 0, function* () { defaultErrorModalWalletNotFoundHandler(); });
5015
+ return async () => {
5016
+ defaultErrorModalWalletNotFoundHandler();
5017
+ };
4790
5018
  }
4791
-
4792
- const CACHE_KEY = 'SolanaMobileWalletAdapterDefaultAuthorizationCache';
5019
+ //#endregion
5020
+ //#region src/createDefaultAuthorizationCache.ts
5021
+ const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
4793
5022
  function createDefaultAuthorizationCache() {
4794
- let storage;
4795
- try {
4796
- storage = window.localStorage;
4797
- // eslint-disable-next-line no-empty
4798
- }
4799
- catch (_a) { }
4800
- return {
4801
- clear() {
4802
- return __awaiter(this, void 0, void 0, function* () {
4803
- if (!storage) {
4804
- return;
4805
- }
4806
- try {
4807
- storage.removeItem(CACHE_KEY);
4808
- // eslint-disable-next-line no-empty
4809
- }
4810
- catch (_a) { }
4811
- });
4812
- },
4813
- get() {
4814
- return __awaiter(this, void 0, void 0, function* () {
4815
- if (!storage) {
4816
- return;
4817
- }
4818
- try {
4819
- const parsed = JSON.parse(storage.getItem(CACHE_KEY));
4820
- if (parsed && parsed.accounts) {
4821
- const parsedAccounts = parsed.accounts.map((account) => {
4822
- return Object.assign(Object.assign({}, account), { publicKey: 'publicKey' in account
4823
- ? new Uint8Array(Object.values(account.publicKey)) // Rebuild publicKey for WalletAccount
4824
- : base58.decode(account.address) });
4825
- });
4826
- return Object.assign(Object.assign({}, parsed), { accounts: parsedAccounts });
4827
- }
4828
- else
4829
- return parsed || undefined;
4830
- // eslint-disable-next-line no-empty
4831
- }
4832
- catch (_a) { }
4833
- });
4834
- },
4835
- set(authorization) {
4836
- return __awaiter(this, void 0, void 0, function* () {
4837
- if (!storage) {
4838
- return;
4839
- }
4840
- try {
4841
- storage.setItem(CACHE_KEY, JSON.stringify(authorization));
4842
- // eslint-disable-next-line no-empty
4843
- }
4844
- catch (_a) { }
4845
- });
4846
- },
4847
- };
5023
+ let storage;
5024
+ try {
5025
+ storage = window.localStorage;
5026
+ } catch {}
5027
+ return {
5028
+ async clear() {
5029
+ if (!storage) return;
5030
+ try {
5031
+ storage.removeItem(CACHE_KEY);
5032
+ } catch {}
5033
+ },
5034
+ async get() {
5035
+ if (!storage) return;
5036
+ try {
5037
+ const parsed = JSON.parse(storage.getItem(CACHE_KEY));
5038
+ if (parsed && parsed.accounts) {
5039
+ const parsedAccounts = parsed.accounts.map((account) => {
5040
+ return {
5041
+ ...account,
5042
+ publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : index.base58.decode(account.address)
5043
+ };
5044
+ });
5045
+ return {
5046
+ ...parsed,
5047
+ accounts: parsedAccounts
5048
+ };
5049
+ } else return parsed || void 0;
5050
+ } catch {}
5051
+ },
5052
+ async set(authorization) {
5053
+ if (!storage) return;
5054
+ try {
5055
+ storage.setItem(CACHE_KEY, JSON.stringify(authorization));
5056
+ } catch {}
5057
+ }
5058
+ };
4848
5059
  }
4849
-
5060
+ //#endregion
5061
+ //#region src/createDefaultChainSelector.ts
4850
5062
  function createDefaultChainSelector() {
4851
- return {
4852
- select(chains) {
4853
- return __awaiter(this, void 0, void 0, function* () {
4854
- if (chains.length === 1) {
4855
- return chains[0];
4856
- }
4857
- else if (chains.includes(SOLANA_MAINNET_CHAIN)) {
4858
- return SOLANA_MAINNET_CHAIN;
4859
- }
4860
- else
4861
- return chains[0];
4862
- });
4863
- },
4864
- };
5063
+ return { async select(chains) {
5064
+ if (chains.length === 1) return chains[0];
5065
+ else if (chains.includes(SOLANA_MAINNET_CHAIN)) return SOLANA_MAINNET_CHAIN;
5066
+ else return chains[0];
5067
+ } };
4865
5068
  }
4866
5069
 
4867
5070
  exports.LocalSolanaMobileWalletAdapterWallet = LocalSolanaMobileWalletAdapterWallet;
@@ -4873,4 +5076,4 @@ exports.createDefaultChainSelector = createDefaultChainSelector;
4873
5076
  exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
4874
5077
  exports.defaultErrorModalWalletNotFoundHandler = defaultErrorModalWalletNotFoundHandler;
4875
5078
  exports.registerMwa = registerMwa;
4876
- //# sourceMappingURL=index.browser-DHi7UhqF.js.map
5079
+ //# sourceMappingURL=index.browser-CT6PUv9G.js.map