@txnlab/use-wallet-solid 3.10.0 → 3.10.1

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 (43) hide show
  1. package/dist/chunk/2PXYBV4S.jsx +883 -0
  2. package/dist/chunk/3J6PRJNJ.mjs +779 -0
  3. package/dist/chunk/3YPORCKB.mjs +9324 -0
  4. package/dist/chunk/ASHSTAAQ.mjs +663 -0
  5. package/dist/chunk/B3UVEMEI.mjs +835 -0
  6. package/dist/chunk/BCEWTVZW.mjs +16644 -0
  7. package/dist/chunk/CL7LX3O4.jsx +50 -0
  8. package/dist/chunk/DTJ3ICHE.mjs +9 -0
  9. package/dist/chunk/FNEO6DUO.jsx +14 -0
  10. package/dist/chunk/GZ2UQYCA.jsx +669 -0
  11. package/dist/chunk/JH7OXUIR.jsx +9903 -0
  12. package/dist/chunk/NVDRUCO3.mjs +26243 -0
  13. package/dist/chunk/QI4NUZHP.jsx +5862 -0
  14. package/dist/chunk/RBDWDJFQ.jsx +17199 -0
  15. package/dist/chunk/UC3ZO4ZH.jsx +802 -0
  16. package/dist/chunk/VDTK67K2.jsx +26395 -0
  17. package/dist/chunk/VJFC7YOA.jsx +2033 -0
  18. package/dist/chunk/VN53D6CR.mjs +2017 -0
  19. package/dist/chunk/VQQ4CVTZ.mjs +5782 -0
  20. package/dist/chunk/ZKJS654W.mjs +42 -0
  21. package/dist/dev.jsx +7198 -74
  22. package/dist/dist/25NR5LQ4.jsx +31 -0
  23. package/dist/dist/3QPHXTX5.jsx +5761 -0
  24. package/dist/dist/5PS5TLM7.mjs +5693 -0
  25. package/dist/dist/COR5WEDJ.jsx +8960 -0
  26. package/dist/dist/DHO5MJBE.mjs +2155 -0
  27. package/dist/dist/DZNWO3EY.mjs +1122 -0
  28. package/dist/dist/H257YD3M.mjs +17103 -0
  29. package/dist/dist/MZFJYXGG.mjs +25 -0
  30. package/dist/dist/NMTOQNMX.jsx +17167 -0
  31. package/dist/dist/OHC5XXJA.jsx +2203 -0
  32. package/dist/dist/XMT4I4HQ.jsx +1139 -0
  33. package/dist/dist/YFXWD6WV.mjs +8864 -0
  34. package/dist/index.es/OIZOTLR7.mjs +9547 -0
  35. package/dist/index.es/R4EQEDY3.jsx +9843 -0
  36. package/dist/index.js +126260 -524
  37. package/dist/index.mjs +7747 -0
  38. package/dist/lib/H7DSBKBW.mjs +10583 -0
  39. package/dist/lib/OYOWTODQ.jsx +10641 -0
  40. package/dist/main.esm/27PE3FUE.jsx +114 -0
  41. package/dist/main.esm/FGHXFDWN.mjs +112 -0
  42. package/package.json +2 -2
  43. package/dist/index.cjs +0 -694
@@ -0,0 +1,779 @@
1
+ // ../../node_modules/.pnpm/proxy-compare@2.5.1/node_modules/proxy-compare/dist/index.modern.js
2
+ var t = Symbol();
3
+ var s = Object.getPrototypeOf;
4
+ var c = /* @__PURE__ */ new WeakMap();
5
+ var l = (e2) => e2 && (c.has(e2) ? c.get(e2) : s(e2) === Object.prototype || s(e2) === Array.prototype);
6
+ var y = (e2) => l(e2) && e2[t] || null;
7
+ var h = (e2, t2 = true) => {
8
+ c.set(e2, t2);
9
+ };
10
+
11
+ // ../../node_modules/.pnpm/valtio@1.11.2_@types+react@18.3.11_react@18.3.1/node_modules/valtio/esm/vanilla.mjs
12
+ var isObject = (x) => typeof x === "object" && x !== null;
13
+ var proxyStateMap = /* @__PURE__ */ new WeakMap();
14
+ var refSet = /* @__PURE__ */ new WeakSet();
15
+ var buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), defaultHandlePromise = (promise) => {
16
+ switch (promise.status) {
17
+ case "fulfilled":
18
+ return promise.value;
19
+ case "rejected":
20
+ throw promise.reason;
21
+ default:
22
+ throw promise;
23
+ }
24
+ }, snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version, handlePromise = defaultHandlePromise) => {
25
+ const cache = snapCache.get(target);
26
+ if ((cache == null ? void 0 : cache[0]) === version) {
27
+ return cache[1];
28
+ }
29
+ const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
30
+ h(snap, true);
31
+ snapCache.set(target, [version, snap]);
32
+ Reflect.ownKeys(target).forEach((key) => {
33
+ if (Object.getOwnPropertyDescriptor(snap, key)) {
34
+ return;
35
+ }
36
+ const value = Reflect.get(target, key);
37
+ const desc = {
38
+ value,
39
+ enumerable: true,
40
+ // This is intentional to avoid copying with proxy-compare.
41
+ // It's still non-writable, so it avoids assigning a value.
42
+ configurable: true
43
+ };
44
+ if (refSet.has(value)) {
45
+ h(value, false);
46
+ } else if (value instanceof Promise) {
47
+ delete desc.value;
48
+ desc.get = () => handlePromise(value);
49
+ } else if (proxyStateMap.has(value)) {
50
+ const [target2, ensureVersion] = proxyStateMap.get(
51
+ value
52
+ );
53
+ desc.value = createSnapshot(
54
+ target2,
55
+ ensureVersion(),
56
+ handlePromise
57
+ );
58
+ }
59
+ Object.defineProperty(snap, key, desc);
60
+ });
61
+ return Object.preventExtensions(snap);
62
+ }, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => {
63
+ if (!isObject(initialObject)) {
64
+ throw new Error("object required");
65
+ }
66
+ const found = proxyCache.get(initialObject);
67
+ if (found) {
68
+ return found;
69
+ }
70
+ let version = versionHolder[0];
71
+ const listeners = /* @__PURE__ */ new Set();
72
+ const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => {
73
+ if (version !== nextVersion) {
74
+ version = nextVersion;
75
+ listeners.forEach((listener) => listener(op, nextVersion));
76
+ }
77
+ };
78
+ let checkVersion = versionHolder[1];
79
+ const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => {
80
+ if (checkVersion !== nextCheckVersion && !listeners.size) {
81
+ checkVersion = nextCheckVersion;
82
+ propProxyStates.forEach(([propProxyState]) => {
83
+ const propVersion = propProxyState[1](nextCheckVersion);
84
+ if (propVersion > version) {
85
+ version = propVersion;
86
+ }
87
+ });
88
+ }
89
+ return version;
90
+ };
91
+ const createPropListener = (prop) => (op, nextVersion) => {
92
+ const newOp = [...op];
93
+ newOp[1] = [prop, ...newOp[1]];
94
+ notifyUpdate(newOp, nextVersion);
95
+ };
96
+ const propProxyStates = /* @__PURE__ */ new Map();
97
+ const addPropListener = (prop, propProxyState) => {
98
+ if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && propProxyStates.has(prop)) {
99
+ throw new Error("prop listener already exists");
100
+ }
101
+ if (listeners.size) {
102
+ const remove = propProxyState[3](createPropListener(prop));
103
+ propProxyStates.set(prop, [propProxyState, remove]);
104
+ } else {
105
+ propProxyStates.set(prop, [propProxyState]);
106
+ }
107
+ };
108
+ const removePropListener = (prop) => {
109
+ var _a;
110
+ const entry = propProxyStates.get(prop);
111
+ if (entry) {
112
+ propProxyStates.delete(prop);
113
+ (_a = entry[1]) == null ? void 0 : _a.call(entry);
114
+ }
115
+ };
116
+ const addListener = (listener) => {
117
+ listeners.add(listener);
118
+ if (listeners.size === 1) {
119
+ propProxyStates.forEach(([propProxyState, prevRemove], prop) => {
120
+ if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && prevRemove) {
121
+ throw new Error("remove already exists");
122
+ }
123
+ const remove = propProxyState[3](createPropListener(prop));
124
+ propProxyStates.set(prop, [propProxyState, remove]);
125
+ });
126
+ }
127
+ const removeListener = () => {
128
+ listeners.delete(listener);
129
+ if (listeners.size === 0) {
130
+ propProxyStates.forEach(([propProxyState, remove], prop) => {
131
+ if (remove) {
132
+ remove();
133
+ propProxyStates.set(prop, [propProxyState]);
134
+ }
135
+ });
136
+ }
137
+ };
138
+ return removeListener;
139
+ };
140
+ const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
141
+ const handler = {
142
+ deleteProperty(target, prop) {
143
+ const prevValue = Reflect.get(target, prop);
144
+ removePropListener(prop);
145
+ const deleted = Reflect.deleteProperty(target, prop);
146
+ if (deleted) {
147
+ notifyUpdate(["delete", [prop], prevValue]);
148
+ }
149
+ return deleted;
150
+ },
151
+ set(target, prop, value, receiver) {
152
+ const hasPrevValue = Reflect.has(target, prop);
153
+ const prevValue = Reflect.get(target, prop, receiver);
154
+ if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) {
155
+ return true;
156
+ }
157
+ removePropListener(prop);
158
+ if (isObject(value)) {
159
+ value = y(value) || value;
160
+ }
161
+ let nextValue = value;
162
+ if (value instanceof Promise) {
163
+ value.then((v) => {
164
+ value.status = "fulfilled";
165
+ value.value = v;
166
+ notifyUpdate(["resolve", [prop], v]);
167
+ }).catch((e2) => {
168
+ value.status = "rejected";
169
+ value.reason = e2;
170
+ notifyUpdate(["reject", [prop], e2]);
171
+ });
172
+ } else {
173
+ if (!proxyStateMap.has(value) && canProxy(value)) {
174
+ nextValue = proxyFunction(value);
175
+ }
176
+ const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue);
177
+ if (childProxyState) {
178
+ addPropListener(prop, childProxyState);
179
+ }
180
+ }
181
+ Reflect.set(target, prop, nextValue, receiver);
182
+ notifyUpdate(["set", [prop], value, prevValue]);
183
+ return true;
184
+ }
185
+ };
186
+ const proxyObject = newProxy(baseObject, handler);
187
+ proxyCache.set(initialObject, proxyObject);
188
+ const proxyState = [
189
+ baseObject,
190
+ ensureVersion,
191
+ createSnapshot,
192
+ addListener
193
+ ];
194
+ proxyStateMap.set(proxyObject, proxyState);
195
+ Reflect.ownKeys(initialObject).forEach((key) => {
196
+ const desc = Object.getOwnPropertyDescriptor(
197
+ initialObject,
198
+ key
199
+ );
200
+ if ("value" in desc) {
201
+ proxyObject[key] = initialObject[key];
202
+ delete desc.value;
203
+ delete desc.writable;
204
+ }
205
+ Object.defineProperty(baseObject, key, desc);
206
+ });
207
+ return proxyObject;
208
+ }) => [
209
+ // public functions
210
+ proxyFunction,
211
+ // shared state
212
+ proxyStateMap,
213
+ refSet,
214
+ // internal things
215
+ objectIs,
216
+ newProxy,
217
+ canProxy,
218
+ defaultHandlePromise,
219
+ snapCache,
220
+ createSnapshot,
221
+ proxyCache,
222
+ versionHolder
223
+ ];
224
+ var [defaultProxyFunction] = buildProxyFunction();
225
+ function proxy(initialObject = {}) {
226
+ return defaultProxyFunction(initialObject);
227
+ }
228
+ function subscribe(proxyObject, callback, notifyInSync) {
229
+ const proxyState = proxyStateMap.get(proxyObject);
230
+ if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !proxyState) ;
231
+ let promise;
232
+ const ops = [];
233
+ const addListener = proxyState[3];
234
+ let isListenerActive = false;
235
+ const listener = (op) => {
236
+ ops.push(op);
237
+ if (!promise) {
238
+ promise = Promise.resolve().then(() => {
239
+ promise = void 0;
240
+ if (isListenerActive) {
241
+ callback(ops.splice(0));
242
+ }
243
+ });
244
+ }
245
+ };
246
+ const removeListener = addListener(listener);
247
+ isListenerActive = true;
248
+ return () => {
249
+ isListenerActive = false;
250
+ removeListener();
251
+ };
252
+ }
253
+ function snapshot(proxyObject, handlePromise) {
254
+ const proxyState = proxyStateMap.get(proxyObject);
255
+ if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !proxyState) ;
256
+ const [target, ensureVersion, createSnapshot] = proxyState;
257
+ return createSnapshot(target, ensureVersion(), handlePromise);
258
+ }
259
+
260
+ // ../../node_modules/.pnpm/@walletconnect+modal-core@2.7.0_@types+react@18.3.11_react@18.3.1/node_modules/@walletconnect/modal-core/dist/index.js
261
+ var state$7 = proxy({
262
+ history: ["ConnectWallet"],
263
+ view: "ConnectWallet",
264
+ data: void 0
265
+ });
266
+ var RouterCtrl = {
267
+ state: state$7,
268
+ subscribe(callback) {
269
+ return subscribe(state$7, () => callback(state$7));
270
+ },
271
+ push(view, data) {
272
+ if (view !== state$7.view) {
273
+ state$7.view = view;
274
+ if (data) {
275
+ state$7.data = data;
276
+ }
277
+ state$7.history.push(view);
278
+ }
279
+ },
280
+ reset(view) {
281
+ state$7.view = view;
282
+ state$7.history = [view];
283
+ },
284
+ replace(view) {
285
+ if (state$7.history.length > 1) {
286
+ state$7.history[state$7.history.length - 1] = view;
287
+ state$7.view = view;
288
+ }
289
+ },
290
+ goBack() {
291
+ if (state$7.history.length > 1) {
292
+ state$7.history.pop();
293
+ const [last] = state$7.history.slice(-1);
294
+ state$7.view = last;
295
+ }
296
+ },
297
+ setData(data) {
298
+ state$7.data = data;
299
+ }
300
+ };
301
+ var CoreUtil = {
302
+ WALLETCONNECT_DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE",
303
+ WCM_VERSION: "WCM_VERSION",
304
+ RECOMMENDED_WALLET_AMOUNT: 9,
305
+ isMobile() {
306
+ if (typeof window !== "undefined") {
307
+ return Boolean(
308
+ window.matchMedia("(pointer:coarse)").matches || /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)
309
+ );
310
+ }
311
+ return false;
312
+ },
313
+ isAndroid() {
314
+ return CoreUtil.isMobile() && navigator.userAgent.toLowerCase().includes("android");
315
+ },
316
+ isIos() {
317
+ const ua = navigator.userAgent.toLowerCase();
318
+ return CoreUtil.isMobile() && (ua.includes("iphone") || ua.includes("ipad"));
319
+ },
320
+ isHttpUrl(url) {
321
+ return url.startsWith("http://") || url.startsWith("https://");
322
+ },
323
+ isArray(data) {
324
+ return Array.isArray(data) && data.length > 0;
325
+ },
326
+ isTelegram() {
327
+ return typeof window !== "undefined" && // eslint-disable-next-line @typescript-eslint/no-explicit-any
328
+ (Boolean(window.TelegramWebviewProxy) || // eslint-disable-next-line @typescript-eslint/no-explicit-any
329
+ Boolean(window.Telegram) || // eslint-disable-next-line @typescript-eslint/no-explicit-any
330
+ Boolean(window.TelegramWebviewProxyProto));
331
+ },
332
+ formatNativeUrl(appUrl, wcUri, name) {
333
+ if (CoreUtil.isHttpUrl(appUrl)) {
334
+ return this.formatUniversalUrl(appUrl, wcUri, name);
335
+ }
336
+ let safeAppUrl = appUrl;
337
+ if (!safeAppUrl.includes("://")) {
338
+ safeAppUrl = appUrl.replaceAll("/", "").replaceAll(":", "");
339
+ safeAppUrl = `${safeAppUrl}://`;
340
+ }
341
+ if (!safeAppUrl.endsWith("/")) {
342
+ safeAppUrl = `${safeAppUrl}/`;
343
+ }
344
+ this.setWalletConnectDeepLink(safeAppUrl, name);
345
+ const encodedWcUrl = encodeURIComponent(wcUri);
346
+ return `${safeAppUrl}wc?uri=${encodedWcUrl}`;
347
+ },
348
+ formatUniversalUrl(appUrl, wcUri, name) {
349
+ if (!CoreUtil.isHttpUrl(appUrl)) {
350
+ return this.formatNativeUrl(appUrl, wcUri, name);
351
+ }
352
+ let safeAppUrl = appUrl;
353
+ if (safeAppUrl.startsWith("https://t.me")) {
354
+ const formattedUri = Buffer.from(wcUri).toString("base64").replace(/[=]/g, "");
355
+ if (safeAppUrl.endsWith("/")) {
356
+ safeAppUrl = safeAppUrl.slice(0, -1);
357
+ }
358
+ this.setWalletConnectDeepLink(safeAppUrl, name);
359
+ const url = new URL(safeAppUrl);
360
+ url.searchParams.set("startapp", formattedUri);
361
+ const link = url.toString();
362
+ return link;
363
+ }
364
+ if (!safeAppUrl.endsWith("/")) {
365
+ safeAppUrl = `${safeAppUrl}/`;
366
+ }
367
+ this.setWalletConnectDeepLink(safeAppUrl, name);
368
+ const encodedWcUrl = encodeURIComponent(wcUri);
369
+ return `${safeAppUrl}wc?uri=${encodedWcUrl}`;
370
+ },
371
+ async wait(miliseconds) {
372
+ return new Promise((resolve) => {
373
+ setTimeout(resolve, miliseconds);
374
+ });
375
+ },
376
+ openHref(href, target) {
377
+ const adjustedTarget = this.isTelegram() ? "_blank" : target;
378
+ window.open(href, adjustedTarget, "noreferrer noopener");
379
+ },
380
+ setWalletConnectDeepLink(href, name) {
381
+ try {
382
+ localStorage.setItem(CoreUtil.WALLETCONNECT_DEEPLINK_CHOICE, JSON.stringify({ href, name }));
383
+ } catch (e2) {
384
+ }
385
+ },
386
+ setWalletConnectAndroidDeepLink(wcUri) {
387
+ try {
388
+ const [href] = wcUri.split("?");
389
+ localStorage.setItem(
390
+ CoreUtil.WALLETCONNECT_DEEPLINK_CHOICE,
391
+ JSON.stringify({ href, name: "Android" })
392
+ );
393
+ } catch (e2) {
394
+ }
395
+ },
396
+ removeWalletConnectDeepLink() {
397
+ try {
398
+ localStorage.removeItem(CoreUtil.WALLETCONNECT_DEEPLINK_CHOICE);
399
+ } catch (e2) {
400
+ }
401
+ },
402
+ setModalVersionInStorage() {
403
+ try {
404
+ if (typeof localStorage !== "undefined") {
405
+ localStorage.setItem(CoreUtil.WCM_VERSION, "2.7.0");
406
+ }
407
+ } catch (e2) {
408
+ }
409
+ },
410
+ getWalletRouterData() {
411
+ var _a;
412
+ const routerData = (_a = RouterCtrl.state.data) == null ? void 0 : _a.Wallet;
413
+ if (!routerData) {
414
+ throw new Error('Missing "Wallet" view data');
415
+ }
416
+ return routerData;
417
+ }
418
+ };
419
+ var isEnabled = typeof location !== "undefined" && (location.hostname.includes("localhost") || location.protocol.includes("https"));
420
+ var state$6 = proxy({
421
+ enabled: isEnabled,
422
+ userSessionId: "",
423
+ events: [],
424
+ connectedWalletId: void 0
425
+ });
426
+ var EventsCtrl = {
427
+ state: state$6,
428
+ subscribe(callback) {
429
+ return subscribe(state$6.events, () => callback(snapshot(state$6.events[state$6.events.length - 1])));
430
+ },
431
+ initialize() {
432
+ if (state$6.enabled && typeof (crypto == null ? void 0 : crypto.randomUUID) !== "undefined") {
433
+ state$6.userSessionId = crypto.randomUUID();
434
+ }
435
+ },
436
+ setConnectedWalletId(connectedWalletId) {
437
+ state$6.connectedWalletId = connectedWalletId;
438
+ },
439
+ click(data) {
440
+ if (state$6.enabled) {
441
+ const event = {
442
+ type: "CLICK",
443
+ name: data.name,
444
+ userSessionId: state$6.userSessionId,
445
+ timestamp: Date.now(),
446
+ data
447
+ };
448
+ state$6.events.push(event);
449
+ }
450
+ },
451
+ track(data) {
452
+ if (state$6.enabled) {
453
+ const event = {
454
+ type: "TRACK",
455
+ name: data.name,
456
+ userSessionId: state$6.userSessionId,
457
+ timestamp: Date.now(),
458
+ data
459
+ };
460
+ state$6.events.push(event);
461
+ }
462
+ },
463
+ view(data) {
464
+ if (state$6.enabled) {
465
+ const event = {
466
+ type: "VIEW",
467
+ name: data.name,
468
+ userSessionId: state$6.userSessionId,
469
+ timestamp: Date.now(),
470
+ data
471
+ };
472
+ state$6.events.push(event);
473
+ }
474
+ }
475
+ };
476
+ var state$5 = proxy({
477
+ chains: void 0,
478
+ walletConnectUri: void 0,
479
+ isAuth: false,
480
+ isCustomDesktop: false,
481
+ isCustomMobile: false,
482
+ isDataLoaded: false,
483
+ isUiLoaded: false
484
+ });
485
+ var OptionsCtrl = {
486
+ state: state$5,
487
+ subscribe(callback) {
488
+ return subscribe(state$5, () => callback(state$5));
489
+ },
490
+ setChains(chains) {
491
+ state$5.chains = chains;
492
+ },
493
+ setWalletConnectUri(walletConnectUri) {
494
+ state$5.walletConnectUri = walletConnectUri;
495
+ },
496
+ setIsCustomDesktop(isCustomDesktop) {
497
+ state$5.isCustomDesktop = isCustomDesktop;
498
+ },
499
+ setIsCustomMobile(isCustomMobile) {
500
+ state$5.isCustomMobile = isCustomMobile;
501
+ },
502
+ setIsDataLoaded(isDataLoaded) {
503
+ state$5.isDataLoaded = isDataLoaded;
504
+ },
505
+ setIsUiLoaded(isUiLoaded) {
506
+ state$5.isUiLoaded = isUiLoaded;
507
+ },
508
+ setIsAuth(isAuth) {
509
+ state$5.isAuth = isAuth;
510
+ }
511
+ };
512
+ var state$4 = proxy({
513
+ projectId: "",
514
+ mobileWallets: void 0,
515
+ desktopWallets: void 0,
516
+ walletImages: void 0,
517
+ chains: void 0,
518
+ enableAuthMode: false,
519
+ enableExplorer: true,
520
+ explorerExcludedWalletIds: void 0,
521
+ explorerRecommendedWalletIds: void 0,
522
+ termsOfServiceUrl: void 0,
523
+ privacyPolicyUrl: void 0
524
+ });
525
+ var ConfigCtrl = {
526
+ state: state$4,
527
+ subscribe(callback) {
528
+ return subscribe(state$4, () => callback(state$4));
529
+ },
530
+ setConfig(config) {
531
+ var _a, _b;
532
+ EventsCtrl.initialize();
533
+ OptionsCtrl.setChains(config.chains);
534
+ OptionsCtrl.setIsAuth(Boolean(config.enableAuthMode));
535
+ OptionsCtrl.setIsCustomMobile(Boolean((_a = config.mobileWallets) == null ? void 0 : _a.length));
536
+ OptionsCtrl.setIsCustomDesktop(Boolean((_b = config.desktopWallets) == null ? void 0 : _b.length));
537
+ CoreUtil.setModalVersionInStorage();
538
+ Object.assign(state$4, config);
539
+ }
540
+ };
541
+ var __defProp$2 = Object.defineProperty;
542
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
543
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
544
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
545
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
546
+ var __spreadValues$2 = (a, b) => {
547
+ for (var prop in b || (b = {}))
548
+ if (__hasOwnProp$2.call(b, prop))
549
+ __defNormalProp$2(a, prop, b[prop]);
550
+ if (__getOwnPropSymbols$2)
551
+ for (var prop of __getOwnPropSymbols$2(b)) {
552
+ if (__propIsEnum$2.call(b, prop))
553
+ __defNormalProp$2(a, prop, b[prop]);
554
+ }
555
+ return a;
556
+ };
557
+ var W3M_API = "https://explorer-api.walletconnect.com";
558
+ var SDK_TYPE = "wcm";
559
+ var SDK_VERSION = `js-${"2.7.0"}`;
560
+ async function fetchListings(endpoint, params) {
561
+ const allParams = __spreadValues$2({ sdkType: SDK_TYPE, sdkVersion: SDK_VERSION }, params);
562
+ const url = new URL(endpoint, W3M_API);
563
+ url.searchParams.append("projectId", ConfigCtrl.state.projectId);
564
+ Object.entries(allParams).forEach(([key, value]) => {
565
+ if (value) {
566
+ url.searchParams.append(key, String(value));
567
+ }
568
+ });
569
+ const request = await fetch(url);
570
+ return request.json();
571
+ }
572
+ var ExplorerUtil = {
573
+ async getDesktopListings(params) {
574
+ return fetchListings("/w3m/v1/getDesktopListings", params);
575
+ },
576
+ async getMobileListings(params) {
577
+ return fetchListings("/w3m/v1/getMobileListings", params);
578
+ },
579
+ async getInjectedListings(params) {
580
+ return fetchListings("/w3m/v1/getInjectedListings", params);
581
+ },
582
+ async getAllListings(params) {
583
+ return fetchListings("/w3m/v1/getAllListings", params);
584
+ },
585
+ getWalletImageUrl(imageId) {
586
+ return `${W3M_API}/w3m/v1/getWalletImage/${imageId}?projectId=${ConfigCtrl.state.projectId}&sdkType=${SDK_TYPE}&sdkVersion=${SDK_VERSION}`;
587
+ },
588
+ getAssetImageUrl(imageId) {
589
+ return `${W3M_API}/w3m/v1/getAssetImage/${imageId}?projectId=${ConfigCtrl.state.projectId}&sdkType=${SDK_TYPE}&sdkVersion=${SDK_VERSION}`;
590
+ }
591
+ };
592
+ var __defProp$1 = Object.defineProperty;
593
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
594
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
595
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
596
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
597
+ var __spreadValues$1 = (a, b) => {
598
+ for (var prop in b || (b = {}))
599
+ if (__hasOwnProp$1.call(b, prop))
600
+ __defNormalProp$1(a, prop, b[prop]);
601
+ if (__getOwnPropSymbols$1)
602
+ for (var prop of __getOwnPropSymbols$1(b)) {
603
+ if (__propIsEnum$1.call(b, prop))
604
+ __defNormalProp$1(a, prop, b[prop]);
605
+ }
606
+ return a;
607
+ };
608
+ var isMobile = CoreUtil.isMobile();
609
+ var state$3 = proxy({
610
+ wallets: { listings: [], total: 0, page: 1 },
611
+ search: { listings: [], total: 0, page: 1 },
612
+ recomendedWallets: []
613
+ });
614
+ var ExplorerCtrl = {
615
+ state: state$3,
616
+ async getRecomendedWallets() {
617
+ const { explorerRecommendedWalletIds, explorerExcludedWalletIds } = ConfigCtrl.state;
618
+ if (explorerRecommendedWalletIds === "NONE" || explorerExcludedWalletIds === "ALL" && !explorerRecommendedWalletIds) {
619
+ return state$3.recomendedWallets;
620
+ }
621
+ if (CoreUtil.isArray(explorerRecommendedWalletIds)) {
622
+ const recommendedIds = explorerRecommendedWalletIds.join(",");
623
+ const params = { recommendedIds };
624
+ const { listings } = await ExplorerUtil.getAllListings(params);
625
+ const listingsArr = Object.values(listings);
626
+ listingsArr.sort((a, b) => {
627
+ const aIndex = explorerRecommendedWalletIds.indexOf(a.id);
628
+ const bIndex = explorerRecommendedWalletIds.indexOf(b.id);
629
+ return aIndex - bIndex;
630
+ });
631
+ state$3.recomendedWallets = listingsArr;
632
+ } else {
633
+ const { chains, isAuth } = OptionsCtrl.state;
634
+ const chainsFilter = chains == null ? void 0 : chains.join(",");
635
+ const isExcluded = CoreUtil.isArray(explorerExcludedWalletIds);
636
+ const params = {
637
+ page: 1,
638
+ sdks: isAuth ? "auth_v1" : void 0,
639
+ entries: CoreUtil.RECOMMENDED_WALLET_AMOUNT,
640
+ chains: chainsFilter,
641
+ version: 2,
642
+ excludedIds: isExcluded ? explorerExcludedWalletIds.join(",") : void 0
643
+ };
644
+ const { listings } = isMobile ? await ExplorerUtil.getMobileListings(params) : await ExplorerUtil.getDesktopListings(params);
645
+ state$3.recomendedWallets = Object.values(listings);
646
+ }
647
+ return state$3.recomendedWallets;
648
+ },
649
+ async getWallets(params) {
650
+ const extendedParams = __spreadValues$1({}, params);
651
+ const { explorerRecommendedWalletIds, explorerExcludedWalletIds } = ConfigCtrl.state;
652
+ const { recomendedWallets } = state$3;
653
+ if (explorerExcludedWalletIds === "ALL") {
654
+ return state$3.wallets;
655
+ }
656
+ if (recomendedWallets.length) {
657
+ extendedParams.excludedIds = recomendedWallets.map((wallet) => wallet.id).join(",");
658
+ } else if (CoreUtil.isArray(explorerRecommendedWalletIds)) {
659
+ extendedParams.excludedIds = explorerRecommendedWalletIds.join(",");
660
+ }
661
+ if (CoreUtil.isArray(explorerExcludedWalletIds)) {
662
+ extendedParams.excludedIds = [extendedParams.excludedIds, explorerExcludedWalletIds].filter(Boolean).join(",");
663
+ }
664
+ if (OptionsCtrl.state.isAuth) {
665
+ extendedParams.sdks = "auth_v1";
666
+ }
667
+ const { page, search } = params;
668
+ const { listings: listingsObj, total } = isMobile ? await ExplorerUtil.getMobileListings(extendedParams) : await ExplorerUtil.getDesktopListings(extendedParams);
669
+ const listings = Object.values(listingsObj);
670
+ const type = search ? "search" : "wallets";
671
+ state$3[type] = {
672
+ listings: [...state$3[type].listings, ...listings],
673
+ total,
674
+ page: page != null ? page : 1
675
+ };
676
+ return { listings, total };
677
+ },
678
+ getWalletImageUrl(imageId) {
679
+ return ExplorerUtil.getWalletImageUrl(imageId);
680
+ },
681
+ getAssetImageUrl(imageId) {
682
+ return ExplorerUtil.getAssetImageUrl(imageId);
683
+ },
684
+ resetSearch() {
685
+ state$3.search = { listings: [], total: 0, page: 1 };
686
+ }
687
+ };
688
+ var state$2 = proxy({
689
+ open: false
690
+ });
691
+ var ModalCtrl = {
692
+ state: state$2,
693
+ subscribe(callback) {
694
+ return subscribe(state$2, () => callback(state$2));
695
+ },
696
+ async open(options) {
697
+ return new Promise((resolve) => {
698
+ const { isUiLoaded, isDataLoaded } = OptionsCtrl.state;
699
+ CoreUtil.removeWalletConnectDeepLink();
700
+ OptionsCtrl.setWalletConnectUri(options == null ? void 0 : options.uri);
701
+ OptionsCtrl.setChains(options == null ? void 0 : options.chains);
702
+ RouterCtrl.reset("ConnectWallet");
703
+ if (isUiLoaded && isDataLoaded) {
704
+ state$2.open = true;
705
+ resolve();
706
+ } else {
707
+ const interval = setInterval(() => {
708
+ const opts = OptionsCtrl.state;
709
+ if (opts.isUiLoaded && opts.isDataLoaded) {
710
+ clearInterval(interval);
711
+ state$2.open = true;
712
+ resolve();
713
+ }
714
+ }, 200);
715
+ }
716
+ });
717
+ },
718
+ close() {
719
+ state$2.open = false;
720
+ }
721
+ };
722
+ var __defProp = Object.defineProperty;
723
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
724
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
725
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
726
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
727
+ var __spreadValues = (a, b) => {
728
+ for (var prop in b || (b = {}))
729
+ if (__hasOwnProp.call(b, prop))
730
+ __defNormalProp(a, prop, b[prop]);
731
+ if (__getOwnPropSymbols)
732
+ for (var prop of __getOwnPropSymbols(b)) {
733
+ if (__propIsEnum.call(b, prop))
734
+ __defNormalProp(a, prop, b[prop]);
735
+ }
736
+ return a;
737
+ };
738
+ function isDarkMode() {
739
+ return typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)").matches;
740
+ }
741
+ var state$1 = proxy({
742
+ themeMode: isDarkMode() ? "dark" : "light"
743
+ });
744
+ var ThemeCtrl = {
745
+ state: state$1,
746
+ subscribe(callback) {
747
+ return subscribe(state$1, () => callback(state$1));
748
+ },
749
+ setThemeConfig(theme) {
750
+ const { themeMode, themeVariables } = theme;
751
+ if (themeMode) {
752
+ state$1.themeMode = themeMode;
753
+ }
754
+ if (themeVariables) {
755
+ state$1.themeVariables = __spreadValues({}, themeVariables);
756
+ }
757
+ }
758
+ };
759
+ var state = proxy({
760
+ open: false,
761
+ message: "",
762
+ variant: "success"
763
+ });
764
+ var ToastCtrl = {
765
+ state,
766
+ subscribe(callback) {
767
+ return subscribe(state, () => callback(state));
768
+ },
769
+ openToast(message, variant) {
770
+ state.open = true;
771
+ state.message = message;
772
+ state.variant = variant;
773
+ },
774
+ closeToast() {
775
+ state.open = false;
776
+ }
777
+ };
778
+
779
+ export { ConfigCtrl, CoreUtil, EventsCtrl, ExplorerCtrl, ModalCtrl, OptionsCtrl, RouterCtrl, ThemeCtrl, ToastCtrl };