@pollar/react 0.5.3 → 0.6.0

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.
package/dist/index.mjs CHANGED
@@ -1,9 +1,1001 @@
1
1
  'use client';
2
2
  import { AUTH_ERROR_CODES, WalletType, PollarClient } from '@pollar/core';
3
- import { createContext, useState, useEffect, useMemo, useContext, useRef, Component } from 'react';
3
+ import { forwardRef, createContext, useState, useEffect, useRef, useCallback, useMemo, useContext, Component } from 'react';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
 
6
- // src/context.tsx
6
+ var __create = Object.create;
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __commonJS = (cb, mod) => function __require() {
13
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+
32
+ // ../../node_modules/qr.js/lib/ErrorCorrectLevel.js
33
+ var require_ErrorCorrectLevel = __commonJS({
34
+ "../../node_modules/qr.js/lib/ErrorCorrectLevel.js"(exports$1, module) {
35
+ module.exports = {
36
+ L: 1,
37
+ M: 0,
38
+ Q: 3,
39
+ H: 2
40
+ };
41
+ }
42
+ });
43
+
44
+ // ../../node_modules/qr.js/lib/mode.js
45
+ var require_mode = __commonJS({
46
+ "../../node_modules/qr.js/lib/mode.js"(exports$1, module) {
47
+ module.exports = {
48
+ MODE_NUMBER: 1 << 0,
49
+ MODE_ALPHA_NUM: 1 << 1,
50
+ MODE_8BIT_BYTE: 1 << 2,
51
+ MODE_KANJI: 1 << 3
52
+ };
53
+ }
54
+ });
55
+
56
+ // ../../node_modules/qr.js/lib/8BitByte.js
57
+ var require_BitByte = __commonJS({
58
+ "../../node_modules/qr.js/lib/8BitByte.js"(exports$1, module) {
59
+ var mode = require_mode();
60
+ function QR8bitByte(data) {
61
+ this.mode = mode.MODE_8BIT_BYTE;
62
+ this.data = data;
63
+ }
64
+ QR8bitByte.prototype = {
65
+ getLength: function(buffer) {
66
+ return this.data.length;
67
+ },
68
+ write: function(buffer) {
69
+ for (var i = 0; i < this.data.length; i++) {
70
+ buffer.put(this.data.charCodeAt(i), 8);
71
+ }
72
+ }
73
+ };
74
+ module.exports = QR8bitByte;
75
+ }
76
+ });
77
+
78
+ // ../../node_modules/qr.js/lib/RSBlock.js
79
+ var require_RSBlock = __commonJS({
80
+ "../../node_modules/qr.js/lib/RSBlock.js"(exports$1, module) {
81
+ var ECL = require_ErrorCorrectLevel();
82
+ function QRRSBlock(totalCount, dataCount) {
83
+ this.totalCount = totalCount;
84
+ this.dataCount = dataCount;
85
+ }
86
+ QRRSBlock.RS_BLOCK_TABLE = [
87
+ // L
88
+ // M
89
+ // Q
90
+ // H
91
+ // 1
92
+ [1, 26, 19],
93
+ [1, 26, 16],
94
+ [1, 26, 13],
95
+ [1, 26, 9],
96
+ // 2
97
+ [1, 44, 34],
98
+ [1, 44, 28],
99
+ [1, 44, 22],
100
+ [1, 44, 16],
101
+ // 3
102
+ [1, 70, 55],
103
+ [1, 70, 44],
104
+ [2, 35, 17],
105
+ [2, 35, 13],
106
+ // 4
107
+ [1, 100, 80],
108
+ [2, 50, 32],
109
+ [2, 50, 24],
110
+ [4, 25, 9],
111
+ // 5
112
+ [1, 134, 108],
113
+ [2, 67, 43],
114
+ [2, 33, 15, 2, 34, 16],
115
+ [2, 33, 11, 2, 34, 12],
116
+ // 6
117
+ [2, 86, 68],
118
+ [4, 43, 27],
119
+ [4, 43, 19],
120
+ [4, 43, 15],
121
+ // 7
122
+ [2, 98, 78],
123
+ [4, 49, 31],
124
+ [2, 32, 14, 4, 33, 15],
125
+ [4, 39, 13, 1, 40, 14],
126
+ // 8
127
+ [2, 121, 97],
128
+ [2, 60, 38, 2, 61, 39],
129
+ [4, 40, 18, 2, 41, 19],
130
+ [4, 40, 14, 2, 41, 15],
131
+ // 9
132
+ [2, 146, 116],
133
+ [3, 58, 36, 2, 59, 37],
134
+ [4, 36, 16, 4, 37, 17],
135
+ [4, 36, 12, 4, 37, 13],
136
+ // 10
137
+ [2, 86, 68, 2, 87, 69],
138
+ [4, 69, 43, 1, 70, 44],
139
+ [6, 43, 19, 2, 44, 20],
140
+ [6, 43, 15, 2, 44, 16],
141
+ // 11
142
+ [4, 101, 81],
143
+ [1, 80, 50, 4, 81, 51],
144
+ [4, 50, 22, 4, 51, 23],
145
+ [3, 36, 12, 8, 37, 13],
146
+ // 12
147
+ [2, 116, 92, 2, 117, 93],
148
+ [6, 58, 36, 2, 59, 37],
149
+ [4, 46, 20, 6, 47, 21],
150
+ [7, 42, 14, 4, 43, 15],
151
+ // 13
152
+ [4, 133, 107],
153
+ [8, 59, 37, 1, 60, 38],
154
+ [8, 44, 20, 4, 45, 21],
155
+ [12, 33, 11, 4, 34, 12],
156
+ // 14
157
+ [3, 145, 115, 1, 146, 116],
158
+ [4, 64, 40, 5, 65, 41],
159
+ [11, 36, 16, 5, 37, 17],
160
+ [11, 36, 12, 5, 37, 13],
161
+ // 15
162
+ [5, 109, 87, 1, 110, 88],
163
+ [5, 65, 41, 5, 66, 42],
164
+ [5, 54, 24, 7, 55, 25],
165
+ [11, 36, 12],
166
+ // 16
167
+ [5, 122, 98, 1, 123, 99],
168
+ [7, 73, 45, 3, 74, 46],
169
+ [15, 43, 19, 2, 44, 20],
170
+ [3, 45, 15, 13, 46, 16],
171
+ // 17
172
+ [1, 135, 107, 5, 136, 108],
173
+ [10, 74, 46, 1, 75, 47],
174
+ [1, 50, 22, 15, 51, 23],
175
+ [2, 42, 14, 17, 43, 15],
176
+ // 18
177
+ [5, 150, 120, 1, 151, 121],
178
+ [9, 69, 43, 4, 70, 44],
179
+ [17, 50, 22, 1, 51, 23],
180
+ [2, 42, 14, 19, 43, 15],
181
+ // 19
182
+ [3, 141, 113, 4, 142, 114],
183
+ [3, 70, 44, 11, 71, 45],
184
+ [17, 47, 21, 4, 48, 22],
185
+ [9, 39, 13, 16, 40, 14],
186
+ // 20
187
+ [3, 135, 107, 5, 136, 108],
188
+ [3, 67, 41, 13, 68, 42],
189
+ [15, 54, 24, 5, 55, 25],
190
+ [15, 43, 15, 10, 44, 16],
191
+ // 21
192
+ [4, 144, 116, 4, 145, 117],
193
+ [17, 68, 42],
194
+ [17, 50, 22, 6, 51, 23],
195
+ [19, 46, 16, 6, 47, 17],
196
+ // 22
197
+ [2, 139, 111, 7, 140, 112],
198
+ [17, 74, 46],
199
+ [7, 54, 24, 16, 55, 25],
200
+ [34, 37, 13],
201
+ // 23
202
+ [4, 151, 121, 5, 152, 122],
203
+ [4, 75, 47, 14, 76, 48],
204
+ [11, 54, 24, 14, 55, 25],
205
+ [16, 45, 15, 14, 46, 16],
206
+ // 24
207
+ [6, 147, 117, 4, 148, 118],
208
+ [6, 73, 45, 14, 74, 46],
209
+ [11, 54, 24, 16, 55, 25],
210
+ [30, 46, 16, 2, 47, 17],
211
+ // 25
212
+ [8, 132, 106, 4, 133, 107],
213
+ [8, 75, 47, 13, 76, 48],
214
+ [7, 54, 24, 22, 55, 25],
215
+ [22, 45, 15, 13, 46, 16],
216
+ // 26
217
+ [10, 142, 114, 2, 143, 115],
218
+ [19, 74, 46, 4, 75, 47],
219
+ [28, 50, 22, 6, 51, 23],
220
+ [33, 46, 16, 4, 47, 17],
221
+ // 27
222
+ [8, 152, 122, 4, 153, 123],
223
+ [22, 73, 45, 3, 74, 46],
224
+ [8, 53, 23, 26, 54, 24],
225
+ [12, 45, 15, 28, 46, 16],
226
+ // 28
227
+ [3, 147, 117, 10, 148, 118],
228
+ [3, 73, 45, 23, 74, 46],
229
+ [4, 54, 24, 31, 55, 25],
230
+ [11, 45, 15, 31, 46, 16],
231
+ // 29
232
+ [7, 146, 116, 7, 147, 117],
233
+ [21, 73, 45, 7, 74, 46],
234
+ [1, 53, 23, 37, 54, 24],
235
+ [19, 45, 15, 26, 46, 16],
236
+ // 30
237
+ [5, 145, 115, 10, 146, 116],
238
+ [19, 75, 47, 10, 76, 48],
239
+ [15, 54, 24, 25, 55, 25],
240
+ [23, 45, 15, 25, 46, 16],
241
+ // 31
242
+ [13, 145, 115, 3, 146, 116],
243
+ [2, 74, 46, 29, 75, 47],
244
+ [42, 54, 24, 1, 55, 25],
245
+ [23, 45, 15, 28, 46, 16],
246
+ // 32
247
+ [17, 145, 115],
248
+ [10, 74, 46, 23, 75, 47],
249
+ [10, 54, 24, 35, 55, 25],
250
+ [19, 45, 15, 35, 46, 16],
251
+ // 33
252
+ [17, 145, 115, 1, 146, 116],
253
+ [14, 74, 46, 21, 75, 47],
254
+ [29, 54, 24, 19, 55, 25],
255
+ [11, 45, 15, 46, 46, 16],
256
+ // 34
257
+ [13, 145, 115, 6, 146, 116],
258
+ [14, 74, 46, 23, 75, 47],
259
+ [44, 54, 24, 7, 55, 25],
260
+ [59, 46, 16, 1, 47, 17],
261
+ // 35
262
+ [12, 151, 121, 7, 152, 122],
263
+ [12, 75, 47, 26, 76, 48],
264
+ [39, 54, 24, 14, 55, 25],
265
+ [22, 45, 15, 41, 46, 16],
266
+ // 36
267
+ [6, 151, 121, 14, 152, 122],
268
+ [6, 75, 47, 34, 76, 48],
269
+ [46, 54, 24, 10, 55, 25],
270
+ [2, 45, 15, 64, 46, 16],
271
+ // 37
272
+ [17, 152, 122, 4, 153, 123],
273
+ [29, 74, 46, 14, 75, 47],
274
+ [49, 54, 24, 10, 55, 25],
275
+ [24, 45, 15, 46, 46, 16],
276
+ // 38
277
+ [4, 152, 122, 18, 153, 123],
278
+ [13, 74, 46, 32, 75, 47],
279
+ [48, 54, 24, 14, 55, 25],
280
+ [42, 45, 15, 32, 46, 16],
281
+ // 39
282
+ [20, 147, 117, 4, 148, 118],
283
+ [40, 75, 47, 7, 76, 48],
284
+ [43, 54, 24, 22, 55, 25],
285
+ [10, 45, 15, 67, 46, 16],
286
+ // 40
287
+ [19, 148, 118, 6, 149, 119],
288
+ [18, 75, 47, 31, 76, 48],
289
+ [34, 54, 24, 34, 55, 25],
290
+ [20, 45, 15, 61, 46, 16]
291
+ ];
292
+ QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
293
+ var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
294
+ if (rsBlock == void 0) {
295
+ throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
296
+ }
297
+ var length = rsBlock.length / 3;
298
+ var list = new Array();
299
+ for (var i = 0; i < length; i++) {
300
+ var count = rsBlock[i * 3 + 0];
301
+ var totalCount = rsBlock[i * 3 + 1];
302
+ var dataCount = rsBlock[i * 3 + 2];
303
+ for (var j = 0; j < count; j++) {
304
+ list.push(new QRRSBlock(totalCount, dataCount));
305
+ }
306
+ }
307
+ return list;
308
+ };
309
+ QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
310
+ switch (errorCorrectLevel) {
311
+ case ECL.L:
312
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
313
+ case ECL.M:
314
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
315
+ case ECL.Q:
316
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
317
+ case ECL.H:
318
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
319
+ default:
320
+ return void 0;
321
+ }
322
+ };
323
+ module.exports = QRRSBlock;
324
+ }
325
+ });
326
+
327
+ // ../../node_modules/qr.js/lib/BitBuffer.js
328
+ var require_BitBuffer = __commonJS({
329
+ "../../node_modules/qr.js/lib/BitBuffer.js"(exports$1, module) {
330
+ function QRBitBuffer() {
331
+ this.buffer = new Array();
332
+ this.length = 0;
333
+ }
334
+ QRBitBuffer.prototype = {
335
+ get: function(index) {
336
+ var bufIndex = Math.floor(index / 8);
337
+ return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
338
+ },
339
+ put: function(num, length) {
340
+ for (var i = 0; i < length; i++) {
341
+ this.putBit((num >>> length - i - 1 & 1) == 1);
342
+ }
343
+ },
344
+ getLengthInBits: function() {
345
+ return this.length;
346
+ },
347
+ putBit: function(bit) {
348
+ var bufIndex = Math.floor(this.length / 8);
349
+ if (this.buffer.length <= bufIndex) {
350
+ this.buffer.push(0);
351
+ }
352
+ if (bit) {
353
+ this.buffer[bufIndex] |= 128 >>> this.length % 8;
354
+ }
355
+ this.length++;
356
+ }
357
+ };
358
+ module.exports = QRBitBuffer;
359
+ }
360
+ });
361
+
362
+ // ../../node_modules/qr.js/lib/math.js
363
+ var require_math = __commonJS({
364
+ "../../node_modules/qr.js/lib/math.js"(exports$1, module) {
365
+ var QRMath = {
366
+ glog: function(n) {
367
+ if (n < 1) {
368
+ throw new Error("glog(" + n + ")");
369
+ }
370
+ return QRMath.LOG_TABLE[n];
371
+ },
372
+ gexp: function(n) {
373
+ while (n < 0) {
374
+ n += 255;
375
+ }
376
+ while (n >= 256) {
377
+ n -= 255;
378
+ }
379
+ return QRMath.EXP_TABLE[n];
380
+ },
381
+ EXP_TABLE: new Array(256),
382
+ LOG_TABLE: new Array(256)
383
+ };
384
+ for (i = 0; i < 8; i++) {
385
+ QRMath.EXP_TABLE[i] = 1 << i;
386
+ }
387
+ var i;
388
+ for (i = 8; i < 256; i++) {
389
+ QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
390
+ }
391
+ var i;
392
+ for (i = 0; i < 255; i++) {
393
+ QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
394
+ }
395
+ var i;
396
+ module.exports = QRMath;
397
+ }
398
+ });
399
+
400
+ // ../../node_modules/qr.js/lib/Polynomial.js
401
+ var require_Polynomial = __commonJS({
402
+ "../../node_modules/qr.js/lib/Polynomial.js"(exports$1, module) {
403
+ var math = require_math();
404
+ function QRPolynomial(num, shift) {
405
+ if (num.length == void 0) {
406
+ throw new Error(num.length + "/" + shift);
407
+ }
408
+ var offset = 0;
409
+ while (offset < num.length && num[offset] == 0) {
410
+ offset++;
411
+ }
412
+ this.num = new Array(num.length - offset + shift);
413
+ for (var i = 0; i < num.length - offset; i++) {
414
+ this.num[i] = num[i + offset];
415
+ }
416
+ }
417
+ QRPolynomial.prototype = {
418
+ get: function(index) {
419
+ return this.num[index];
420
+ },
421
+ getLength: function() {
422
+ return this.num.length;
423
+ },
424
+ multiply: function(e) {
425
+ var num = new Array(this.getLength() + e.getLength() - 1);
426
+ for (var i = 0; i < this.getLength(); i++) {
427
+ for (var j = 0; j < e.getLength(); j++) {
428
+ num[i + j] ^= math.gexp(math.glog(this.get(i)) + math.glog(e.get(j)));
429
+ }
430
+ }
431
+ return new QRPolynomial(num, 0);
432
+ },
433
+ mod: function(e) {
434
+ if (this.getLength() - e.getLength() < 0) {
435
+ return this;
436
+ }
437
+ var ratio = math.glog(this.get(0)) - math.glog(e.get(0));
438
+ var num = new Array(this.getLength());
439
+ for (var i = 0; i < this.getLength(); i++) {
440
+ num[i] = this.get(i);
441
+ }
442
+ for (var i = 0; i < e.getLength(); i++) {
443
+ num[i] ^= math.gexp(math.glog(e.get(i)) + ratio);
444
+ }
445
+ return new QRPolynomial(num, 0).mod(e);
446
+ }
447
+ };
448
+ module.exports = QRPolynomial;
449
+ }
450
+ });
451
+
452
+ // ../../node_modules/qr.js/lib/util.js
453
+ var require_util = __commonJS({
454
+ "../../node_modules/qr.js/lib/util.js"(exports$1, module) {
455
+ var Mode = require_mode();
456
+ var Polynomial = require_Polynomial();
457
+ var math = require_math();
458
+ var QRMaskPattern = {
459
+ PATTERN000: 0,
460
+ PATTERN001: 1,
461
+ PATTERN010: 2,
462
+ PATTERN011: 3,
463
+ PATTERN100: 4,
464
+ PATTERN101: 5,
465
+ PATTERN110: 6,
466
+ PATTERN111: 7
467
+ };
468
+ var QRUtil = {
469
+ PATTERN_POSITION_TABLE: [
470
+ [],
471
+ [6, 18],
472
+ [6, 22],
473
+ [6, 26],
474
+ [6, 30],
475
+ [6, 34],
476
+ [6, 22, 38],
477
+ [6, 24, 42],
478
+ [6, 26, 46],
479
+ [6, 28, 50],
480
+ [6, 30, 54],
481
+ [6, 32, 58],
482
+ [6, 34, 62],
483
+ [6, 26, 46, 66],
484
+ [6, 26, 48, 70],
485
+ [6, 26, 50, 74],
486
+ [6, 30, 54, 78],
487
+ [6, 30, 56, 82],
488
+ [6, 30, 58, 86],
489
+ [6, 34, 62, 90],
490
+ [6, 28, 50, 72, 94],
491
+ [6, 26, 50, 74, 98],
492
+ [6, 30, 54, 78, 102],
493
+ [6, 28, 54, 80, 106],
494
+ [6, 32, 58, 84, 110],
495
+ [6, 30, 58, 86, 114],
496
+ [6, 34, 62, 90, 118],
497
+ [6, 26, 50, 74, 98, 122],
498
+ [6, 30, 54, 78, 102, 126],
499
+ [6, 26, 52, 78, 104, 130],
500
+ [6, 30, 56, 82, 108, 134],
501
+ [6, 34, 60, 86, 112, 138],
502
+ [6, 30, 58, 86, 114, 142],
503
+ [6, 34, 62, 90, 118, 146],
504
+ [6, 30, 54, 78, 102, 126, 150],
505
+ [6, 24, 50, 76, 102, 128, 154],
506
+ [6, 28, 54, 80, 106, 132, 158],
507
+ [6, 32, 58, 84, 110, 136, 162],
508
+ [6, 26, 54, 82, 110, 138, 166],
509
+ [6, 30, 58, 86, 114, 142, 170]
510
+ ],
511
+ G15: 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0,
512
+ G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0,
513
+ G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1,
514
+ getBCHTypeInfo: function(data) {
515
+ var d = data << 10;
516
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
517
+ d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15);
518
+ }
519
+ return (data << 10 | d) ^ QRUtil.G15_MASK;
520
+ },
521
+ getBCHTypeNumber: function(data) {
522
+ var d = data << 12;
523
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
524
+ d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);
525
+ }
526
+ return data << 12 | d;
527
+ },
528
+ getBCHDigit: function(data) {
529
+ var digit = 0;
530
+ while (data != 0) {
531
+ digit++;
532
+ data >>>= 1;
533
+ }
534
+ return digit;
535
+ },
536
+ getPatternPosition: function(typeNumber) {
537
+ return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
538
+ },
539
+ getMask: function(maskPattern, i, j) {
540
+ switch (maskPattern) {
541
+ case QRMaskPattern.PATTERN000:
542
+ return (i + j) % 2 == 0;
543
+ case QRMaskPattern.PATTERN001:
544
+ return i % 2 == 0;
545
+ case QRMaskPattern.PATTERN010:
546
+ return j % 3 == 0;
547
+ case QRMaskPattern.PATTERN011:
548
+ return (i + j) % 3 == 0;
549
+ case QRMaskPattern.PATTERN100:
550
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
551
+ case QRMaskPattern.PATTERN101:
552
+ return i * j % 2 + i * j % 3 == 0;
553
+ case QRMaskPattern.PATTERN110:
554
+ return (i * j % 2 + i * j % 3) % 2 == 0;
555
+ case QRMaskPattern.PATTERN111:
556
+ return (i * j % 3 + (i + j) % 2) % 2 == 0;
557
+ default:
558
+ throw new Error("bad maskPattern:" + maskPattern);
559
+ }
560
+ },
561
+ getErrorCorrectPolynomial: function(errorCorrectLength) {
562
+ var a = new Polynomial([1], 0);
563
+ for (var i = 0; i < errorCorrectLength; i++) {
564
+ a = a.multiply(new Polynomial([1, math.gexp(i)], 0));
565
+ }
566
+ return a;
567
+ },
568
+ getLengthInBits: function(mode, type) {
569
+ if (1 <= type && type < 10) {
570
+ switch (mode) {
571
+ case Mode.MODE_NUMBER:
572
+ return 10;
573
+ case Mode.MODE_ALPHA_NUM:
574
+ return 9;
575
+ case Mode.MODE_8BIT_BYTE:
576
+ return 8;
577
+ case Mode.MODE_KANJI:
578
+ return 8;
579
+ default:
580
+ throw new Error("mode:" + mode);
581
+ }
582
+ } else if (type < 27) {
583
+ switch (mode) {
584
+ case Mode.MODE_NUMBER:
585
+ return 12;
586
+ case Mode.MODE_ALPHA_NUM:
587
+ return 11;
588
+ case Mode.MODE_8BIT_BYTE:
589
+ return 16;
590
+ case Mode.MODE_KANJI:
591
+ return 10;
592
+ default:
593
+ throw new Error("mode:" + mode);
594
+ }
595
+ } else if (type < 41) {
596
+ switch (mode) {
597
+ case Mode.MODE_NUMBER:
598
+ return 14;
599
+ case Mode.MODE_ALPHA_NUM:
600
+ return 13;
601
+ case Mode.MODE_8BIT_BYTE:
602
+ return 16;
603
+ case Mode.MODE_KANJI:
604
+ return 12;
605
+ default:
606
+ throw new Error("mode:" + mode);
607
+ }
608
+ } else {
609
+ throw new Error("type:" + type);
610
+ }
611
+ },
612
+ getLostPoint: function(qrCode) {
613
+ var moduleCount = qrCode.getModuleCount();
614
+ var lostPoint = 0;
615
+ for (var row = 0; row < moduleCount; row++) {
616
+ for (var col = 0; col < moduleCount; col++) {
617
+ var sameCount = 0;
618
+ var dark = qrCode.isDark(row, col);
619
+ for (var r = -1; r <= 1; r++) {
620
+ if (row + r < 0 || moduleCount <= row + r) {
621
+ continue;
622
+ }
623
+ for (var c = -1; c <= 1; c++) {
624
+ if (col + c < 0 || moduleCount <= col + c) {
625
+ continue;
626
+ }
627
+ if (r == 0 && c == 0) {
628
+ continue;
629
+ }
630
+ if (dark == qrCode.isDark(row + r, col + c)) {
631
+ sameCount++;
632
+ }
633
+ }
634
+ }
635
+ if (sameCount > 5) {
636
+ lostPoint += 3 + sameCount - 5;
637
+ }
638
+ }
639
+ }
640
+ for (var row = 0; row < moduleCount - 1; row++) {
641
+ for (var col = 0; col < moduleCount - 1; col++) {
642
+ var count = 0;
643
+ if (qrCode.isDark(row, col)) count++;
644
+ if (qrCode.isDark(row + 1, col)) count++;
645
+ if (qrCode.isDark(row, col + 1)) count++;
646
+ if (qrCode.isDark(row + 1, col + 1)) count++;
647
+ if (count == 0 || count == 4) {
648
+ lostPoint += 3;
649
+ }
650
+ }
651
+ }
652
+ for (var row = 0; row < moduleCount; row++) {
653
+ for (var col = 0; col < moduleCount - 6; col++) {
654
+ if (qrCode.isDark(row, col) && !qrCode.isDark(row, col + 1) && qrCode.isDark(row, col + 2) && qrCode.isDark(row, col + 3) && qrCode.isDark(row, col + 4) && !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6)) {
655
+ lostPoint += 40;
656
+ }
657
+ }
658
+ }
659
+ for (var col = 0; col < moduleCount; col++) {
660
+ for (var row = 0; row < moduleCount - 6; row++) {
661
+ if (qrCode.isDark(row, col) && !qrCode.isDark(row + 1, col) && qrCode.isDark(row + 2, col) && qrCode.isDark(row + 3, col) && qrCode.isDark(row + 4, col) && !qrCode.isDark(row + 5, col) && qrCode.isDark(row + 6, col)) {
662
+ lostPoint += 40;
663
+ }
664
+ }
665
+ }
666
+ var darkCount = 0;
667
+ for (var col = 0; col < moduleCount; col++) {
668
+ for (var row = 0; row < moduleCount; row++) {
669
+ if (qrCode.isDark(row, col)) {
670
+ darkCount++;
671
+ }
672
+ }
673
+ }
674
+ var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
675
+ lostPoint += ratio * 10;
676
+ return lostPoint;
677
+ }
678
+ };
679
+ module.exports = QRUtil;
680
+ }
681
+ });
682
+
683
+ // ../../node_modules/qr.js/lib/QRCode.js
684
+ var require_QRCode = __commonJS({
685
+ "../../node_modules/qr.js/lib/QRCode.js"(exports$1, module) {
686
+ var BitByte = require_BitByte();
687
+ var RSBlock = require_RSBlock();
688
+ var BitBuffer = require_BitBuffer();
689
+ var util = require_util();
690
+ var Polynomial = require_Polynomial();
691
+ function QRCode3(typeNumber, errorCorrectLevel) {
692
+ this.typeNumber = typeNumber;
693
+ this.errorCorrectLevel = errorCorrectLevel;
694
+ this.modules = null;
695
+ this.moduleCount = 0;
696
+ this.dataCache = null;
697
+ this.dataList = [];
698
+ }
699
+ var proto = QRCode3.prototype;
700
+ proto.addData = function(data) {
701
+ var newData = new BitByte(data);
702
+ this.dataList.push(newData);
703
+ this.dataCache = null;
704
+ };
705
+ proto.isDark = function(row, col) {
706
+ if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
707
+ throw new Error(row + "," + col);
708
+ }
709
+ return this.modules[row][col];
710
+ };
711
+ proto.getModuleCount = function() {
712
+ return this.moduleCount;
713
+ };
714
+ proto.make = function() {
715
+ if (this.typeNumber < 1) {
716
+ var typeNumber = 1;
717
+ for (typeNumber = 1; typeNumber < 40; typeNumber++) {
718
+ var rsBlocks = RSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
719
+ var buffer = new BitBuffer();
720
+ var totalDataCount = 0;
721
+ for (var i = 0; i < rsBlocks.length; i++) {
722
+ totalDataCount += rsBlocks[i].dataCount;
723
+ }
724
+ for (var i = 0; i < this.dataList.length; i++) {
725
+ var data = this.dataList[i];
726
+ buffer.put(data.mode, 4);
727
+ buffer.put(data.getLength(), util.getLengthInBits(data.mode, typeNumber));
728
+ data.write(buffer);
729
+ }
730
+ if (buffer.getLengthInBits() <= totalDataCount * 8)
731
+ break;
732
+ }
733
+ this.typeNumber = typeNumber;
734
+ }
735
+ this.makeImpl(false, this.getBestMaskPattern());
736
+ };
737
+ proto.makeImpl = function(test, maskPattern) {
738
+ this.moduleCount = this.typeNumber * 4 + 17;
739
+ this.modules = new Array(this.moduleCount);
740
+ for (var row = 0; row < this.moduleCount; row++) {
741
+ this.modules[row] = new Array(this.moduleCount);
742
+ for (var col = 0; col < this.moduleCount; col++) {
743
+ this.modules[row][col] = null;
744
+ }
745
+ }
746
+ this.setupPositionProbePattern(0, 0);
747
+ this.setupPositionProbePattern(this.moduleCount - 7, 0);
748
+ this.setupPositionProbePattern(0, this.moduleCount - 7);
749
+ this.setupPositionAdjustPattern();
750
+ this.setupTimingPattern();
751
+ this.setupTypeInfo(test, maskPattern);
752
+ if (this.typeNumber >= 7) {
753
+ this.setupTypeNumber(test);
754
+ }
755
+ if (this.dataCache == null) {
756
+ this.dataCache = QRCode3.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
757
+ }
758
+ this.mapData(this.dataCache, maskPattern);
759
+ };
760
+ proto.setupPositionProbePattern = function(row, col) {
761
+ for (var r = -1; r <= 7; r++) {
762
+ if (row + r <= -1 || this.moduleCount <= row + r) continue;
763
+ for (var c = -1; c <= 7; c++) {
764
+ if (col + c <= -1 || this.moduleCount <= col + c) continue;
765
+ if (0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) {
766
+ this.modules[row + r][col + c] = true;
767
+ } else {
768
+ this.modules[row + r][col + c] = false;
769
+ }
770
+ }
771
+ }
772
+ };
773
+ proto.getBestMaskPattern = function() {
774
+ var minLostPoint = 0;
775
+ var pattern = 0;
776
+ for (var i = 0; i < 8; i++) {
777
+ this.makeImpl(true, i);
778
+ var lostPoint = util.getLostPoint(this);
779
+ if (i == 0 || minLostPoint > lostPoint) {
780
+ minLostPoint = lostPoint;
781
+ pattern = i;
782
+ }
783
+ }
784
+ return pattern;
785
+ };
786
+ proto.createMovieClip = function(target_mc, instance_name, depth) {
787
+ var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
788
+ var cs = 1;
789
+ this.make();
790
+ for (var row = 0; row < this.modules.length; row++) {
791
+ var y = row * cs;
792
+ for (var col = 0; col < this.modules[row].length; col++) {
793
+ var x = col * cs;
794
+ var dark = this.modules[row][col];
795
+ if (dark) {
796
+ qr_mc.beginFill(0, 100);
797
+ qr_mc.moveTo(x, y);
798
+ qr_mc.lineTo(x + cs, y);
799
+ qr_mc.lineTo(x + cs, y + cs);
800
+ qr_mc.lineTo(x, y + cs);
801
+ qr_mc.endFill();
802
+ }
803
+ }
804
+ }
805
+ return qr_mc;
806
+ };
807
+ proto.setupTimingPattern = function() {
808
+ for (var r = 8; r < this.moduleCount - 8; r++) {
809
+ if (this.modules[r][6] != null) {
810
+ continue;
811
+ }
812
+ this.modules[r][6] = r % 2 == 0;
813
+ }
814
+ for (var c = 8; c < this.moduleCount - 8; c++) {
815
+ if (this.modules[6][c] != null) {
816
+ continue;
817
+ }
818
+ this.modules[6][c] = c % 2 == 0;
819
+ }
820
+ };
821
+ proto.setupPositionAdjustPattern = function() {
822
+ var pos = util.getPatternPosition(this.typeNumber);
823
+ for (var i = 0; i < pos.length; i++) {
824
+ for (var j = 0; j < pos.length; j++) {
825
+ var row = pos[i];
826
+ var col = pos[j];
827
+ if (this.modules[row][col] != null) {
828
+ continue;
829
+ }
830
+ for (var r = -2; r <= 2; r++) {
831
+ for (var c = -2; c <= 2; c++) {
832
+ if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) {
833
+ this.modules[row + r][col + c] = true;
834
+ } else {
835
+ this.modules[row + r][col + c] = false;
836
+ }
837
+ }
838
+ }
839
+ }
840
+ }
841
+ };
842
+ proto.setupTypeNumber = function(test) {
843
+ var bits = util.getBCHTypeNumber(this.typeNumber);
844
+ for (var i = 0; i < 18; i++) {
845
+ var mod = !test && (bits >> i & 1) == 1;
846
+ this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
847
+ }
848
+ for (var i = 0; i < 18; i++) {
849
+ var mod = !test && (bits >> i & 1) == 1;
850
+ this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
851
+ }
852
+ };
853
+ proto.setupTypeInfo = function(test, maskPattern) {
854
+ var data = this.errorCorrectLevel << 3 | maskPattern;
855
+ var bits = util.getBCHTypeInfo(data);
856
+ for (var i = 0; i < 15; i++) {
857
+ var mod = !test && (bits >> i & 1) == 1;
858
+ if (i < 6) {
859
+ this.modules[i][8] = mod;
860
+ } else if (i < 8) {
861
+ this.modules[i + 1][8] = mod;
862
+ } else {
863
+ this.modules[this.moduleCount - 15 + i][8] = mod;
864
+ }
865
+ }
866
+ for (var i = 0; i < 15; i++) {
867
+ var mod = !test && (bits >> i & 1) == 1;
868
+ if (i < 8) {
869
+ this.modules[8][this.moduleCount - i - 1] = mod;
870
+ } else if (i < 9) {
871
+ this.modules[8][15 - i - 1 + 1] = mod;
872
+ } else {
873
+ this.modules[8][15 - i - 1] = mod;
874
+ }
875
+ }
876
+ this.modules[this.moduleCount - 8][8] = !test;
877
+ };
878
+ proto.mapData = function(data, maskPattern) {
879
+ var inc = -1;
880
+ var row = this.moduleCount - 1;
881
+ var bitIndex = 7;
882
+ var byteIndex = 0;
883
+ for (var col = this.moduleCount - 1; col > 0; col -= 2) {
884
+ if (col == 6) col--;
885
+ while (true) {
886
+ for (var c = 0; c < 2; c++) {
887
+ if (this.modules[row][col - c] == null) {
888
+ var dark = false;
889
+ if (byteIndex < data.length) {
890
+ dark = (data[byteIndex] >>> bitIndex & 1) == 1;
891
+ }
892
+ var mask = util.getMask(maskPattern, row, col - c);
893
+ if (mask) {
894
+ dark = !dark;
895
+ }
896
+ this.modules[row][col - c] = dark;
897
+ bitIndex--;
898
+ if (bitIndex == -1) {
899
+ byteIndex++;
900
+ bitIndex = 7;
901
+ }
902
+ }
903
+ }
904
+ row += inc;
905
+ if (row < 0 || this.moduleCount <= row) {
906
+ row -= inc;
907
+ inc = -inc;
908
+ break;
909
+ }
910
+ }
911
+ }
912
+ };
913
+ QRCode3.PAD0 = 236;
914
+ QRCode3.PAD1 = 17;
915
+ QRCode3.createData = function(typeNumber, errorCorrectLevel, dataList) {
916
+ var rsBlocks = RSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
917
+ var buffer = new BitBuffer();
918
+ for (var i = 0; i < dataList.length; i++) {
919
+ var data = dataList[i];
920
+ buffer.put(data.mode, 4);
921
+ buffer.put(data.getLength(), util.getLengthInBits(data.mode, typeNumber));
922
+ data.write(buffer);
923
+ }
924
+ var totalDataCount = 0;
925
+ for (var i = 0; i < rsBlocks.length; i++) {
926
+ totalDataCount += rsBlocks[i].dataCount;
927
+ }
928
+ if (buffer.getLengthInBits() > totalDataCount * 8) {
929
+ throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")");
930
+ }
931
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
932
+ buffer.put(0, 4);
933
+ }
934
+ while (buffer.getLengthInBits() % 8 != 0) {
935
+ buffer.putBit(false);
936
+ }
937
+ while (true) {
938
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
939
+ break;
940
+ }
941
+ buffer.put(QRCode3.PAD0, 8);
942
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
943
+ break;
944
+ }
945
+ buffer.put(QRCode3.PAD1, 8);
946
+ }
947
+ return QRCode3.createBytes(buffer, rsBlocks);
948
+ };
949
+ QRCode3.createBytes = function(buffer, rsBlocks) {
950
+ var offset = 0;
951
+ var maxDcCount = 0;
952
+ var maxEcCount = 0;
953
+ var dcdata = new Array(rsBlocks.length);
954
+ var ecdata = new Array(rsBlocks.length);
955
+ for (var r = 0; r < rsBlocks.length; r++) {
956
+ var dcCount = rsBlocks[r].dataCount;
957
+ var ecCount = rsBlocks[r].totalCount - dcCount;
958
+ maxDcCount = Math.max(maxDcCount, dcCount);
959
+ maxEcCount = Math.max(maxEcCount, ecCount);
960
+ dcdata[r] = new Array(dcCount);
961
+ for (var i = 0; i < dcdata[r].length; i++) {
962
+ dcdata[r][i] = 255 & buffer.buffer[i + offset];
963
+ }
964
+ offset += dcCount;
965
+ var rsPoly = util.getErrorCorrectPolynomial(ecCount);
966
+ var rawPoly = new Polynomial(dcdata[r], rsPoly.getLength() - 1);
967
+ var modPoly = rawPoly.mod(rsPoly);
968
+ ecdata[r] = new Array(rsPoly.getLength() - 1);
969
+ for (var i = 0; i < ecdata[r].length; i++) {
970
+ var modIndex = i + modPoly.getLength() - ecdata[r].length;
971
+ ecdata[r][i] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
972
+ }
973
+ }
974
+ var totalCodeCount = 0;
975
+ for (var i = 0; i < rsBlocks.length; i++) {
976
+ totalCodeCount += rsBlocks[i].totalCount;
977
+ }
978
+ var data = new Array(totalCodeCount);
979
+ var index = 0;
980
+ for (var i = 0; i < maxDcCount; i++) {
981
+ for (var r = 0; r < rsBlocks.length; r++) {
982
+ if (i < dcdata[r].length) {
983
+ data[index++] = dcdata[r][i];
984
+ }
985
+ }
986
+ }
987
+ for (var i = 0; i < maxEcCount; i++) {
988
+ for (var r = 0; r < rsBlocks.length; r++) {
989
+ if (i < ecdata[r].length) {
990
+ data[index++] = ecdata[r][i];
991
+ }
992
+ }
993
+ }
994
+ return data;
995
+ };
996
+ module.exports = QRCode3;
997
+ }
998
+ });
7
999
 
8
1000
  // src/constants.ts
9
1001
  var LOGO_POLLAR = "https://pollar.xyz/assets/logo_pollar.png";
@@ -36,7 +1028,7 @@ var PollarModalFooter = () => {
36
1028
  /* @__PURE__ */ jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
37
1029
  /* @__PURE__ */ jsxs("span", { className: "pollar-footer-version", children: [
38
1030
  "v",
39
- "0.5.3"
1031
+ "0.6.0"
40
1032
  ] })
41
1033
  ] })
42
1034
  ] });
@@ -169,8 +1161,8 @@ function KycModal({ onClose, country = "MX", level = "basic", onApproved }) {
169
1161
  const { theme = "light", accentColor = "#005DB4" } = styles;
170
1162
  useEffect(() => {
171
1163
  setIsLoading(true);
172
- client.getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
173
- }, [country]);
1164
+ getClient().getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
1165
+ }, [getClient, country]);
174
1166
  async function handleSelectProvider(provider) {
175
1167
  setSelectedProvider(provider);
176
1168
  setIsLoading(true);
@@ -501,10 +1493,12 @@ function LoginModalTemplate({
501
1493
  }
502
1494
  function LoginModal({ onClose }) {
503
1495
  const [email, setEmail] = useState("");
504
- const { getClient, styles, config } = usePollar();
1496
+ const { getClient, styles, appConfig: config } = usePollar();
505
1497
  const [authState, setAuthState] = useState(() => getClient().getAuthState());
506
1498
  const [codeInputKey, setCodeInputKey] = useState(0);
507
1499
  const pendingEmail = useRef(null);
1500
+ const onCloseRef = useRef(onClose);
1501
+ onCloseRef.current = onClose;
508
1502
  useEffect(() => {
509
1503
  return getClient().onAuthStateChange((next) => {
510
1504
  setAuthState(next);
@@ -516,10 +1510,10 @@ function LoginModal({ onClose }) {
516
1510
  setCodeInputKey((k) => k + 1);
517
1511
  }
518
1512
  if (next.step === "authenticated") {
519
- setTimeout(onClose, 1e3);
1513
+ setTimeout(onCloseRef.current, 1e3);
520
1514
  }
521
1515
  });
522
- }, []);
1516
+ }, [getClient]);
523
1517
  const { theme = "light", accentColor = "#005DB4", logoUrl, emailEnabled, embeddedWallets, providers } = styles;
524
1518
  function handleClose() {
525
1519
  setEmail("");
@@ -581,70 +1575,60 @@ function LoginModal({ onClose }) {
581
1575
  }
582
1576
  ) });
583
1577
  }
584
- var RAIL_LABELS = {
585
- SPEI: "SPEI (Mexico)",
586
- PIX: "PIX (Brazil)",
587
- PSE: "PSE (Colombia)",
588
- ACH: "ACH (US)"
589
- };
590
- function RouteDisplay({ quote, onSelect }) {
591
- return /* @__PURE__ */ jsxs(
592
- "div",
1578
+
1579
+ // src/lib/qr-code/index.tsx
1580
+ var import_ErrorCorrectLevel = __toESM(require_ErrorCorrectLevel());
1581
+ var import_QRCode = __toESM(require_QRCode());
1582
+ var QRCodeSvg = forwardRef(function QRCodeSvg2({
1583
+ bgColor,
1584
+ bgD,
1585
+ fgD,
1586
+ fgColor,
1587
+ size,
1588
+ title,
1589
+ viewBoxSize,
1590
+ xmlns = "http://www.w3.org/2000/svg",
1591
+ ...props
1592
+ }, ref) {
1593
+ return /* @__PURE__ */ jsxs("svg", { ...props, height: size, ref, viewBox: `0 0 ${viewBoxSize} ${viewBoxSize}`, width: size, xmlns, children: [
1594
+ title ? /* @__PURE__ */ jsx("title", { children: title }) : null,
1595
+ /* @__PURE__ */ jsx("path", { d: bgD, fill: bgColor }),
1596
+ /* @__PURE__ */ jsx("path", { d: fgD, fill: fgColor })
1597
+ ] });
1598
+ });
1599
+ QRCodeSvg.displayName = "QRCodeSvg";
1600
+ function bytesToBinaryString(bytes) {
1601
+ return bytes.map((b) => String.fromCharCode(b & 255)).join("");
1602
+ }
1603
+ function encodeStringToUtf8Bytes(input) {
1604
+ return Array.from(new TextEncoder().encode(input));
1605
+ }
1606
+ var QRCode = forwardRef(function QRCode2({ bgColor = "#FFFFFF", fgColor = "#000000", level = "L", size = 256, value, ...props }, ref) {
1607
+ const qrcode = new import_QRCode.default(-1, import_ErrorCorrectLevel.default[level]);
1608
+ const utf8Bytes = encodeStringToUtf8Bytes(value);
1609
+ const binaryString = bytesToBinaryString(utf8Bytes);
1610
+ qrcode.addData(binaryString, "Byte");
1611
+ qrcode.make();
1612
+ const cells = qrcode.modules;
1613
+ return /* @__PURE__ */ jsx(
1614
+ QRCodeSvg,
593
1615
  {
594
- className: "pollar-ramp-route-card",
595
- "data-recommended": quote.recommended,
596
- role: "button",
597
- tabIndex: 0,
598
- onClick: () => onSelect(quote),
599
- onKeyDown: (e) => e.key === "Enter" && onSelect(quote),
600
- children: [
601
- /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-route-left", children: [
602
- /* @__PURE__ */ jsx("span", { className: "pollar-ramp-route-provider", children: quote.provider }),
603
- /* @__PURE__ */ jsxs("span", { className: "pollar-ramp-route-meta", children: [
604
- RAIL_LABELS[quote.rail] ?? quote.rail,
605
- " \xB7 ",
606
- quote.protocol,
607
- " \xB7 ",
608
- quote.estimatedTime
609
- ] })
610
- ] }),
611
- /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-route-right", children: [
612
- /* @__PURE__ */ jsxs("span", { className: "pollar-ramp-route-fee", children: [
613
- quote.fee,
614
- "% fee"
615
- ] }),
616
- quote.recommended && /* @__PURE__ */ jsx("span", { className: "pollar-ramp-route-badge", children: "Best rate" })
617
- ] })
618
- ]
1616
+ ...props,
1617
+ bgColor,
1618
+ bgD: cells.map((row, rowIndex) => row.map((cell, cellIndex) => !cell ? `M ${cellIndex} ${rowIndex} l 1 0 0 1 -1 0 Z` : "").join(" ")).join(" "),
1619
+ fgColor,
1620
+ fgD: cells.map((row, rowIndex) => row.map((cell, cellIndex) => cell ? `M ${cellIndex} ${rowIndex} l 1 0 0 1 -1 0 Z` : "").join(" ")).join(" "),
1621
+ ref,
1622
+ size,
1623
+ viewBoxSize: cells.length
619
1624
  }
620
1625
  );
621
- }
622
- var LOADING_STEPS = ["Detecting your country\u2026", "Consulting providers\u2026", "Route found!"];
623
- var COUNTRY_CURRENCIES = {
624
- MX: "MXN",
625
- BR: "BRL",
626
- CO: "COP",
627
- CL: "CLP",
628
- PE: "PEN",
629
- AR: "ARS"
630
- };
631
- function RampWidgetTemplate({
1626
+ });
1627
+ function ReceiveModalTemplate({
632
1628
  theme,
633
1629
  accentColor,
634
- step,
635
- direction,
636
- amount,
637
- currency,
638
- country,
639
- quotes,
640
- paymentInstructions,
641
- isLoading,
642
- onDirectionChange,
643
- onAmountChange,
644
- onCurrencyChange,
645
- onCountryChange,
646
- onFindRoute,
647
- onSelectQuote,
1630
+ walletAddress,
1631
+ copied,
648
1632
  onCopy,
649
1633
  onClose
650
1634
  }) {
@@ -664,13 +1648,183 @@ function RampWidgetTemplate({
664
1648
  "--pollar-buttons-height": "44px",
665
1649
  "--pollar-input-height": "44px",
666
1650
  "--pollar-input-border-radius": "0.5rem",
667
- "--pollar-card-border-radius": "10px",
668
- "--pollar-modal-padding": "2rem",
669
- "--pollar-modal-heading-size": "1.375rem",
670
- "--pollar-modal-subtitle-size": "0.9rem"
1651
+ "--pollar-card-border-radius": "10px"
671
1652
  };
672
- const stepTitle = {
673
- input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
1653
+ return /* @__PURE__ */ jsxs(
1654
+ "div",
1655
+ {
1656
+ className: "pollar-modal-card pollar-receive-modal",
1657
+ "data-theme": theme,
1658
+ style: cssVars,
1659
+ onClick: (e) => e.stopPropagation(),
1660
+ children: [
1661
+ /* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
1662
+ /* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Receive" }),
1663
+ /* @__PURE__ */ jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }) })
1664
+ ] }),
1665
+ walletAddress ? /* @__PURE__ */ jsxs(Fragment, { children: [
1666
+ /* @__PURE__ */ jsx("div", { className: "pollar-receive-qr", children: /* @__PURE__ */ jsx(
1667
+ QRCode,
1668
+ {
1669
+ value: walletAddress,
1670
+ size: 180,
1671
+ fgColor: isDark ? "#ffffff" : "#111827",
1672
+ bgColor: "transparent"
1673
+ }
1674
+ ) }),
1675
+ /* @__PURE__ */ jsx("p", { className: "pollar-receive-instructions", children: "Share your Stellar address to receive any asset. Only send Stellar assets to this address." }),
1676
+ /* @__PURE__ */ jsxs("div", { className: "pollar-receive-address-row", children: [
1677
+ /* @__PURE__ */ jsx("span", { className: "pollar-receive-address", children: walletAddress }),
1678
+ /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-receive-copy-btn", onClick: onCopy, "aria-label": "Copy address", children: copied ? /* @__PURE__ */ jsxs(Fragment, { children: [
1679
+ /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
1680
+ /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
1681
+ /* @__PURE__ */ jsx(
1682
+ "path",
1683
+ {
1684
+ d: "M3.5 7l2.5 2.5 4.5-5",
1685
+ stroke: "white",
1686
+ strokeWidth: "1.5",
1687
+ strokeLinecap: "round",
1688
+ strokeLinejoin: "round"
1689
+ }
1690
+ )
1691
+ ] }),
1692
+ "Copied!"
1693
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1694
+ /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
1695
+ /* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
1696
+ /* @__PURE__ */ jsx(
1697
+ "path",
1698
+ {
1699
+ d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
1700
+ stroke: "currentColor",
1701
+ strokeWidth: "1.5",
1702
+ strokeLinecap: "round"
1703
+ }
1704
+ )
1705
+ ] }),
1706
+ "Copy address"
1707
+ ] }) })
1708
+ ] })
1709
+ ] }) : /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No wallet connected." }),
1710
+ /* @__PURE__ */ jsx(PollarModalFooter, {})
1711
+ ]
1712
+ }
1713
+ );
1714
+ }
1715
+ function ReceiveModal({ onClose }) {
1716
+ const { walletAddress, styles } = usePollar();
1717
+ const { theme = "light", accentColor = "#005DB4" } = styles;
1718
+ const [copied, setCopied] = useState(false);
1719
+ function handleCopy() {
1720
+ if (!walletAddress) return;
1721
+ navigator.clipboard.writeText(walletAddress).then(() => {
1722
+ setCopied(true);
1723
+ setTimeout(() => setCopied(false), 2e3);
1724
+ });
1725
+ }
1726
+ return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
1727
+ ReceiveModalTemplate,
1728
+ {
1729
+ theme,
1730
+ accentColor,
1731
+ walletAddress,
1732
+ copied,
1733
+ onCopy: handleCopy,
1734
+ onClose
1735
+ }
1736
+ ) });
1737
+ }
1738
+ var RAIL_LABELS = {
1739
+ SPEI: "SPEI (Mexico)",
1740
+ PIX: "PIX (Brazil)",
1741
+ PSE: "PSE (Colombia)",
1742
+ ACH: "ACH (US)"
1743
+ };
1744
+ function RouteDisplay({ quote, onSelect }) {
1745
+ return /* @__PURE__ */ jsxs(
1746
+ "div",
1747
+ {
1748
+ className: "pollar-ramp-route-card",
1749
+ "data-recommended": quote.recommended,
1750
+ role: "button",
1751
+ tabIndex: 0,
1752
+ onClick: () => onSelect(quote),
1753
+ onKeyDown: (e) => e.key === "Enter" && onSelect(quote),
1754
+ children: [
1755
+ /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-route-left", children: [
1756
+ /* @__PURE__ */ jsx("span", { className: "pollar-ramp-route-provider", children: quote.provider }),
1757
+ /* @__PURE__ */ jsxs("span", { className: "pollar-ramp-route-meta", children: [
1758
+ RAIL_LABELS[quote.rail] ?? quote.rail,
1759
+ " \xB7 ",
1760
+ quote.protocol,
1761
+ " \xB7 ",
1762
+ quote.estimatedTime
1763
+ ] })
1764
+ ] }),
1765
+ /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-route-right", children: [
1766
+ /* @__PURE__ */ jsxs("span", { className: "pollar-ramp-route-fee", children: [
1767
+ quote.fee,
1768
+ "% fee"
1769
+ ] }),
1770
+ quote.recommended && /* @__PURE__ */ jsx("span", { className: "pollar-ramp-route-badge", children: "Best rate" })
1771
+ ] })
1772
+ ]
1773
+ }
1774
+ );
1775
+ }
1776
+ var LOADING_STEPS = ["Detecting your country\u2026", "Consulting providers\u2026", "Route found!"];
1777
+ var COUNTRY_CURRENCIES = {
1778
+ MX: "MXN",
1779
+ BR: "BRL",
1780
+ CO: "COP",
1781
+ CL: "CLP",
1782
+ PE: "PEN",
1783
+ AR: "ARS"
1784
+ };
1785
+ function RampWidgetTemplate({
1786
+ theme,
1787
+ accentColor,
1788
+ step,
1789
+ direction,
1790
+ amount,
1791
+ currency,
1792
+ country,
1793
+ quotes,
1794
+ paymentInstructions,
1795
+ isLoading,
1796
+ onDirectionChange,
1797
+ onAmountChange,
1798
+ onCurrencyChange,
1799
+ onCountryChange,
1800
+ onFindRoute,
1801
+ onSelectQuote,
1802
+ onCopy,
1803
+ onClose
1804
+ }) {
1805
+ const isDark = theme === "dark";
1806
+ const cssVars = {
1807
+ "--pollar-accent": accentColor,
1808
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
1809
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
1810
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
1811
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
1812
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
1813
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
1814
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
1815
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
1816
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
1817
+ "--pollar-buttons-border-radius": "6px",
1818
+ "--pollar-buttons-height": "44px",
1819
+ "--pollar-input-height": "44px",
1820
+ "--pollar-input-border-radius": "0.5rem",
1821
+ "--pollar-card-border-radius": "10px",
1822
+ "--pollar-modal-padding": "2rem",
1823
+ "--pollar-modal-heading-size": "1.375rem",
1824
+ "--pollar-modal-subtitle-size": "0.9rem"
1825
+ };
1826
+ const stepTitle = {
1827
+ input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
674
1828
  loading_quote: "Finding best route",
675
1829
  select_route: "Select provider",
676
1830
  payment_instructions: "Payment instructions"
@@ -903,38 +2057,18 @@ var STATUS_MESSAGES = {
903
2057
  success: "Transaction sent successfully",
904
2058
  error: "Transaction failed"
905
2059
  };
906
- function TransactionModalTemplate({
907
- theme,
908
- accentColor,
2060
+ function TxStatusView({
909
2061
  transaction,
910
2062
  showXdr,
911
2063
  copied,
912
2064
  explorerUrl,
913
2065
  walletType,
914
- onClose,
915
2066
  onSignAndSend,
916
2067
  onToggleXdr,
917
2068
  onCopyHash,
918
- onRetry
2069
+ onRetry,
2070
+ onDone
919
2071
  }) {
920
- const isDark = theme === "dark";
921
- const cssVars = {
922
- "--pollar-accent": accentColor,
923
- "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
924
- "--pollar-border": isDark ? "#374151" : "#e5e7eb",
925
- "--pollar-text": isDark ? "#ffffff" : "#111827",
926
- "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
927
- "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
928
- "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
929
- "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
930
- "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
931
- "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
932
- "--pollar-buttons-border-radius": "6px",
933
- "--pollar-buttons-height": "44px",
934
- "--pollar-input-height": "44px",
935
- "--pollar-input-border-radius": "0.5rem",
936
- "--pollar-card-border-radius": "10px"
937
- };
938
2072
  const buildData = "buildData" in transaction ? transaction.buildData : null;
939
2073
  const hash = transaction.step === "success" ? transaction.hash : null;
940
2074
  const errorDetails = transaction.step === "error" ? transaction.details ?? null : null;
@@ -943,23 +2077,9 @@ function TransactionModalTemplate({
943
2077
  const isSuccess = transaction.step === "success";
944
2078
  const isError = transaction.step === "error";
945
2079
  const showDetails = buildData !== null && (isBuilt || isSigning || isSuccess);
946
- return /* @__PURE__ */ jsxs("div", { className: "pollar-modal-card pollar-tx-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
947
- /* @__PURE__ */ jsx("div", { className: "pollar-modal-header", children: /* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Transaction" }) }),
948
- /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-close-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx(
949
- "svg",
950
- {
951
- width: "18",
952
- height: "18",
953
- viewBox: "0 0 24 24",
954
- fill: "none",
955
- stroke: "currentColor",
956
- strokeWidth: "2.5",
957
- strokeLinecap: "round",
958
- strokeLinejoin: "round",
959
- "aria-hidden": true,
960
- children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
961
- }
962
- ) }),
2080
+ const walletImg = walletType === WalletType.FREIGHTER ? LOGO_FREIGHTER : walletType === WalletType.ALBEDO ? LOGO_ALBEDO : LOGO_POLLAR;
2081
+ const walletAlt = walletType === WalletType.FREIGHTER ? "Freighter" : walletType === WalletType.ALBEDO ? "Albedo" : "Pollar";
2082
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
963
2083
  showDetails && buildData && /* @__PURE__ */ jsxs(Fragment, { children: [
964
2084
  /* @__PURE__ */ jsxs("div", { className: "pollar-tx-summary", children: [
965
2085
  /* @__PURE__ */ jsx("p", { className: "pollar-tx-summary-title", children: "Details" }),
@@ -1029,14 +2149,7 @@ function TransactionModalTemplate({
1029
2149
  ]
1030
2150
  }
1031
2151
  ),
1032
- /* @__PURE__ */ jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsx(
1033
- "img",
1034
- {
1035
- src: walletType === WalletType.FREIGHTER ? LOGO_FREIGHTER : walletType === WalletType.ALBEDO ? LOGO_ALBEDO : LOGO_POLLAR,
1036
- alt: walletType === WalletType.FREIGHTER ? "Freighter" : walletType === WalletType.ALBEDO ? "Albedo" : "Pollar",
1037
- className: "pollar-tx-wallet-img"
1038
- }
1039
- ) })
2152
+ /* @__PURE__ */ jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsx("img", { src: walletImg, alt: walletAlt, className: "pollar-tx-wallet-img" }) })
1040
2153
  ] }),
1041
2154
  isSigning && /* @__PURE__ */ jsx("p", { className: "pollar-tx-spinner-label", children: walletType === WalletType.FREIGHTER ? "Waiting for Freighter\u2026" : walletType === WalletType.ALBEDO ? "Waiting for Albedo\u2026" : "Signing and sending\u2026" }),
1042
2155
  isError && onRetry && "buildData" in transaction && transaction.buildData && /* @__PURE__ */ jsx("button", { className: "pollar-btn-secondary pollar-tx-retry-btn", onClick: onRetry, children: "Try again" })
@@ -1101,19 +2214,369 @@ function TransactionModalTemplate({
1101
2214
  ] })
1102
2215
  ] })
1103
2216
  ] }),
1104
- isSuccess && /* @__PURE__ */ jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onClose, children: "Done" }),
2217
+ isSuccess && /* @__PURE__ */ jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onDone, children: "Done" }),
1105
2218
  /* @__PURE__ */ jsx(
1106
2219
  ModalStatusBanner,
1107
2220
  {
1108
2221
  message: STATUS_MESSAGES[transaction.step],
1109
2222
  status: isError ? "ERROR" : isSigning || transaction.step === "building" ? "LOADING" : isSuccess ? "SUCCESS" : "NONE"
1110
2223
  }
1111
- ),
1112
- /* @__PURE__ */ jsx(PollarModalFooter, {})
2224
+ )
1113
2225
  ] });
1114
2226
  }
2227
+ function formatBalance(balance) {
2228
+ const n = parseFloat(balance);
2229
+ return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
2230
+ }
2231
+ function assetKey(record) {
2232
+ return `${record.code}:${record.issuer ?? "native"}`;
2233
+ }
2234
+ function SendModalTemplate({
2235
+ theme,
2236
+ accentColor,
2237
+ step,
2238
+ txTitle,
2239
+ assets,
2240
+ selectedAsset,
2241
+ amount,
2242
+ destination,
2243
+ formError,
2244
+ isLoadingBalance,
2245
+ transaction,
2246
+ showXdr,
2247
+ copied,
2248
+ explorerUrl,
2249
+ walletType,
2250
+ showBack,
2251
+ isInProgress,
2252
+ onClose,
2253
+ onBack,
2254
+ onSelectAsset,
2255
+ onAmountChange,
2256
+ onDestinationChange,
2257
+ onSubmit,
2258
+ onSignAndSend,
2259
+ onToggleXdr,
2260
+ onCopyHash,
2261
+ onRetry,
2262
+ onDone
2263
+ }) {
2264
+ const isDark = theme === "dark";
2265
+ const cssVars = {
2266
+ "--pollar-accent": accentColor,
2267
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
2268
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
2269
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
2270
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
2271
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2272
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2273
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
2274
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
2275
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2276
+ "--pollar-buttons-border-radius": "6px",
2277
+ "--pollar-buttons-height": "44px",
2278
+ "--pollar-input-height": "44px",
2279
+ "--pollar-input-border-radius": "0.5rem",
2280
+ "--pollar-card-border-radius": "10px"
2281
+ };
2282
+ const enabledAssets = assets.filter((a) => a.enabledInApp);
2283
+ const otherAssets = assets.filter((a) => !a.enabledInApp);
2284
+ const selectedKey = selectedAsset ? assetKey(selectedAsset) : "";
2285
+ const canSubmit = !!selectedAsset && !!amount && !!destination.trim() && !isLoadingBalance;
2286
+ const title = step === "form" ? "Send" : txTitle;
2287
+ return /* @__PURE__ */ jsxs(
2288
+ "div",
2289
+ {
2290
+ className: "pollar-modal-card pollar-send-modal",
2291
+ "data-theme": theme,
2292
+ style: cssVars,
2293
+ onClick: (e) => e.stopPropagation(),
2294
+ children: [
2295
+ /* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
2296
+ /* @__PURE__ */ jsxs("div", { className: "pollar-send-header-left", children: [
2297
+ showBack && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onBack, "aria-label": "Back", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
2298
+ /* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: title })
2299
+ ] }),
2300
+ !isInProgress && /* @__PURE__ */ jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }) })
2301
+ ] }),
2302
+ step === "form" && /* @__PURE__ */ jsxs(Fragment, { children: [
2303
+ /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
2304
+ /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Asset" }),
2305
+ isLoadingBalance ? /* @__PURE__ */ jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxs(
2306
+ "select",
2307
+ {
2308
+ className: "pollar-input pollar-send-select",
2309
+ value: selectedKey,
2310
+ onChange: (e) => {
2311
+ const all = [...enabledAssets, ...otherAssets];
2312
+ const found = all.find((a) => assetKey(a) === e.target.value);
2313
+ if (found) onSelectAsset(found);
2314
+ },
2315
+ children: [
2316
+ /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select asset" }),
2317
+ enabledAssets.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: "App assets", children: enabledAssets.map((a) => /* @__PURE__ */ jsxs("option", { value: assetKey(a), children: [
2318
+ a.code,
2319
+ " \u2014 ",
2320
+ formatBalance(a.available),
2321
+ " available"
2322
+ ] }, assetKey(a))) }),
2323
+ otherAssets.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: "Other assets", children: otherAssets.map((a) => /* @__PURE__ */ jsxs("option", { value: assetKey(a), children: [
2324
+ a.code,
2325
+ " \u2014 ",
2326
+ formatBalance(a.available),
2327
+ " available"
2328
+ ] }, assetKey(a))) })
2329
+ ]
2330
+ }
2331
+ )
2332
+ ] }),
2333
+ /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
2334
+ /* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
2335
+ /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Amount" }),
2336
+ selectedAsset && /* @__PURE__ */ jsxs("span", { className: "pollar-send-hint", children: [
2337
+ "Available: ",
2338
+ formatBalance(selectedAsset.available),
2339
+ " ",
2340
+ selectedAsset.code
2341
+ ] })
2342
+ ] }),
2343
+ /* @__PURE__ */ jsx(
2344
+ "input",
2345
+ {
2346
+ className: "pollar-input",
2347
+ type: "text",
2348
+ inputMode: "decimal",
2349
+ placeholder: "0.00",
2350
+ value: amount,
2351
+ onChange: (e) => onAmountChange(e.target.value)
2352
+ }
2353
+ )
2354
+ ] }),
2355
+ /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
2356
+ /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Destination wallet" }),
2357
+ /* @__PURE__ */ jsx(
2358
+ "input",
2359
+ {
2360
+ className: "pollar-input",
2361
+ type: "text",
2362
+ placeholder: "G\u2026",
2363
+ value: destination,
2364
+ onChange: (e) => onDestinationChange(e.target.value)
2365
+ }
2366
+ )
2367
+ ] }),
2368
+ formError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: formError }),
2369
+ /* @__PURE__ */ jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsx("button", { className: "pollar-btn-primary", onClick: onSubmit, disabled: !canSubmit, children: "Continue" }) })
2370
+ ] }),
2371
+ step === "tx" && /* @__PURE__ */ jsx(
2372
+ TxStatusView,
2373
+ {
2374
+ transaction,
2375
+ showXdr,
2376
+ copied,
2377
+ explorerUrl,
2378
+ walletType,
2379
+ onSignAndSend,
2380
+ onToggleXdr,
2381
+ onCopyHash,
2382
+ onRetry,
2383
+ onDone
2384
+ }
2385
+ ),
2386
+ /* @__PURE__ */ jsx(PollarModalFooter, {})
2387
+ ]
2388
+ }
2389
+ );
2390
+ }
2391
+ function assetParam(record) {
2392
+ if (record.type === "native") return { type: "native" };
2393
+ if (record.type === "credit_alphanum4") {
2394
+ return { type: "credit_alphanum4", code: record.code, issuer: record.issuer };
2395
+ }
2396
+ return { type: "credit_alphanum12", code: record.code, issuer: record.issuer };
2397
+ }
2398
+ function SendModal({ onClose }) {
2399
+ const { walletBalance, refreshWalletBalance, buildTx, signAndSubmitTx, tx: transaction, walletType, network, styles } = usePollar();
2400
+ const { theme = "light", accentColor = "#005DB4" } = styles;
2401
+ const [step, setStep] = useState("form");
2402
+ const [amount, setAmount] = useState("");
2403
+ const [destination, setDestination] = useState("");
2404
+ const [selectedAsset, setSelectedAsset] = useState(null);
2405
+ const [showXdr, setShowXdr] = useState(false);
2406
+ const [copied, setCopied] = useState(false);
2407
+ const [formError, setFormError] = useState("");
2408
+ useEffect(() => {
2409
+ void refreshWalletBalance();
2410
+ }, [refreshWalletBalance]);
2411
+ const balanceData = walletBalance.step === "loaded" ? walletBalance.data : null;
2412
+ const allAssets = balanceData?.balances ?? [];
2413
+ const sortedAssets = [
2414
+ ...allAssets.filter((b) => b.enabledInApp),
2415
+ ...allAssets.filter((b) => !b.enabledInApp && parseFloat(b.balance) > 0)
2416
+ ];
2417
+ const hash = transaction.step === "success" ? transaction.hash : null;
2418
+ const buildData = "buildData" in transaction ? transaction.buildData : null;
2419
+ const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
2420
+ const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
2421
+ const isInProgress = transaction.step === "building" || transaction.step === "signing";
2422
+ const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
2423
+ const txTitle = transaction.step === "signing" ? "Sending\u2026" : transaction.step === "success" ? "Sent!" : transaction.step === "error" ? "Send failed" : "Confirm Send";
2424
+ async function handleSubmit() {
2425
+ setFormError("");
2426
+ if (!selectedAsset) {
2427
+ setFormError("Select an asset");
2428
+ return;
2429
+ }
2430
+ const parsed = parseFloat(amount);
2431
+ if (!amount || isNaN(parsed) || parsed <= 0) {
2432
+ setFormError("Enter a valid amount");
2433
+ return;
2434
+ }
2435
+ if (parsed > parseFloat(selectedAsset.available)) {
2436
+ setFormError("Insufficient balance");
2437
+ return;
2438
+ }
2439
+ if (!destination.trim()) {
2440
+ setFormError("Enter a destination address");
2441
+ return;
2442
+ }
2443
+ setStep("tx");
2444
+ await buildTx("payment", { destination: destination.trim(), amount, asset: assetParam(selectedAsset) });
2445
+ }
2446
+ function handleSignAndSend() {
2447
+ if (transaction.step === "built") {
2448
+ void signAndSubmitTx(transaction.buildData.unsignedXdr);
2449
+ }
2450
+ }
2451
+ function handleCopyHash() {
2452
+ if (!hash) return;
2453
+ navigator.clipboard.writeText(hash).then(() => {
2454
+ setCopied(true);
2455
+ setTimeout(() => setCopied(false), 2e3);
2456
+ });
2457
+ }
2458
+ async function handleRetry() {
2459
+ if (transaction.step === "error" && transaction.buildData) {
2460
+ await signAndSubmitTx(transaction.buildData.unsignedXdr);
2461
+ }
2462
+ }
2463
+ function handleBack() {
2464
+ setStep("form");
2465
+ setShowXdr(false);
2466
+ setCopied(false);
2467
+ }
2468
+ return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsx(
2469
+ SendModalTemplate,
2470
+ {
2471
+ theme,
2472
+ accentColor,
2473
+ step,
2474
+ txTitle,
2475
+ assets: sortedAssets,
2476
+ selectedAsset,
2477
+ amount,
2478
+ destination,
2479
+ formError,
2480
+ isLoadingBalance: walletBalance.step === "loading",
2481
+ transaction,
2482
+ showXdr,
2483
+ copied,
2484
+ explorerUrl,
2485
+ walletType,
2486
+ showBack,
2487
+ isInProgress,
2488
+ onClose,
2489
+ onBack: handleBack,
2490
+ onSelectAsset: setSelectedAsset,
2491
+ onAmountChange: setAmount,
2492
+ onDestinationChange: setDestination,
2493
+ onSubmit: () => void handleSubmit(),
2494
+ onSignAndSend: handleSignAndSend,
2495
+ onToggleXdr: () => setShowXdr((v) => !v),
2496
+ onCopyHash: handleCopyHash,
2497
+ onRetry: () => void handleRetry(),
2498
+ onDone: onClose
2499
+ }
2500
+ ) });
2501
+ }
2502
+ function TransactionModalTemplate({
2503
+ theme,
2504
+ accentColor,
2505
+ transaction,
2506
+ showXdr,
2507
+ copied,
2508
+ explorerUrl,
2509
+ walletType,
2510
+ onClose,
2511
+ onSignAndSend,
2512
+ onToggleXdr,
2513
+ onCopyHash,
2514
+ onRetry
2515
+ }) {
2516
+ const isDark = theme === "dark";
2517
+ const cssVars = {
2518
+ "--pollar-accent": accentColor,
2519
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
2520
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
2521
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
2522
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
2523
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2524
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2525
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
2526
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
2527
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2528
+ "--pollar-buttons-border-radius": "6px",
2529
+ "--pollar-buttons-height": "44px",
2530
+ "--pollar-input-height": "44px",
2531
+ "--pollar-input-border-radius": "0.5rem",
2532
+ "--pollar-card-border-radius": "10px"
2533
+ };
2534
+ return /* @__PURE__ */ jsxs(
2535
+ "div",
2536
+ {
2537
+ className: "pollar-modal-card pollar-tx-modal",
2538
+ "data-theme": theme,
2539
+ style: cssVars,
2540
+ onClick: (e) => e.stopPropagation(),
2541
+ children: [
2542
+ /* @__PURE__ */ jsx("div", { className: "pollar-modal-header", children: /* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Transaction" }) }),
2543
+ /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-close-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx(
2544
+ "svg",
2545
+ {
2546
+ width: "18",
2547
+ height: "18",
2548
+ viewBox: "0 0 24 24",
2549
+ fill: "none",
2550
+ stroke: "currentColor",
2551
+ strokeWidth: "2.5",
2552
+ strokeLinecap: "round",
2553
+ strokeLinejoin: "round",
2554
+ "aria-hidden": true,
2555
+ children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
2556
+ }
2557
+ ) }),
2558
+ /* @__PURE__ */ jsx(
2559
+ TxStatusView,
2560
+ {
2561
+ transaction,
2562
+ showXdr,
2563
+ copied,
2564
+ explorerUrl,
2565
+ walletType,
2566
+ onSignAndSend,
2567
+ onToggleXdr,
2568
+ onCopyHash,
2569
+ onRetry,
2570
+ onDone: onClose
2571
+ }
2572
+ ),
2573
+ /* @__PURE__ */ jsx(PollarModalFooter, {})
2574
+ ]
2575
+ }
2576
+ );
2577
+ }
1115
2578
  function TransactionModal({ onClose }) {
1116
- const { getClient, styles, transaction, network, walletType } = usePollar();
2579
+ const { getClient, styles, tx: transaction, network, walletType } = usePollar();
1117
2580
  const { theme = "light", accentColor = "#005DB4" } = styles;
1118
2581
  const [showXdr, setShowXdr] = useState(false);
1119
2582
  const [copied, setCopied] = useState(false);
@@ -1284,10 +2747,13 @@ function TxHistoryModal({ onClose }) {
1284
2747
  const { getClient, styles, txHistory } = usePollar();
1285
2748
  const { theme = "light", accentColor = "#005DB4" } = styles;
1286
2749
  const [offset, setOffset] = useState(0);
1287
- function load(nextOffset) {
2750
+ const load = useCallback((nextOffset) => {
1288
2751
  setOffset(nextOffset);
1289
2752
  void getClient().fetchTxHistory({ limit: PAGE_SIZE2, offset: nextOffset });
1290
- }
2753
+ }, [getClient]);
2754
+ useEffect(() => {
2755
+ load(0);
2756
+ }, [load]);
1291
2757
  return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
1292
2758
  TxHistoryModalTemplate,
1293
2759
  {
@@ -1302,7 +2768,7 @@ function TxHistoryModal({ onClose }) {
1302
2768
  }
1303
2769
  ) });
1304
2770
  }
1305
- function formatBalance(balance) {
2771
+ function formatBalance2(balance) {
1306
2772
  const n = parseFloat(balance);
1307
2773
  return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
1308
2774
  }
@@ -1315,9 +2781,9 @@ function BalanceItem({ record }) {
1315
2781
  return /* @__PURE__ */ jsxs("div", { className: "pollar-bal-item", children: [
1316
2782
  /* @__PURE__ */ jsx("span", { className: "pollar-bal-asset", children: record.code }),
1317
2783
  /* @__PURE__ */ jsxs("div", { className: "pollar-bal-amounts", children: [
1318
- /* @__PURE__ */ jsx("span", { className: "pollar-bal-amount", children: formatBalance(record.balance) }),
2784
+ /* @__PURE__ */ jsx("span", { className: "pollar-bal-amount", children: formatBalance2(record.balance) }),
1319
2785
  balanceDiffers && /* @__PURE__ */ jsxs("span", { className: "pollar-bal-available", children: [
1320
- formatBalance(record.available),
2786
+ formatBalance2(record.available),
1321
2787
  " available"
1322
2788
  ] })
1323
2789
  ] })
@@ -1390,11 +2856,11 @@ function WalletBalanceModalTemplate({
1390
2856
  ] });
1391
2857
  }
1392
2858
  function WalletBalanceModal({ onClose }) {
1393
- const { walletBalance, refreshBalance, walletAddress, styles } = usePollar();
2859
+ const { walletBalance, refreshWalletBalance, walletAddress, styles } = usePollar();
1394
2860
  const { theme = "light", accentColor = "#005DB4" } = styles;
1395
2861
  useEffect(() => {
1396
- void refreshBalance();
1397
- }, []);
2862
+ void refreshWalletBalance();
2863
+ }, [refreshWalletBalance]);
1398
2864
  return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
1399
2865
  WalletBalanceModalTemplate,
1400
2866
  {
@@ -1402,7 +2868,7 @@ function WalletBalanceModal({ onClose }) {
1402
2868
  accentColor,
1403
2869
  walletBalance,
1404
2870
  walletAddress,
1405
- onRefresh: () => refreshBalance(),
2871
+ onRefresh: () => refreshWalletBalance(),
1406
2872
  onClose
1407
2873
  }
1408
2874
  ) });
@@ -1427,6 +2893,8 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1427
2893
  const [walletBalance, setWalletBalance] = useState({ step: "idle" });
1428
2894
  const [remoteConfig, setRemoteConfig] = useState(emptyResponse);
1429
2895
  const [styles, setStyles] = useState(propStyles ?? {});
2896
+ const propStylesRef = useRef(propStyles);
2897
+ propStylesRef.current = propStyles;
1430
2898
  useEffect(() => {
1431
2899
  return pollarClient.onTransactionStateChange(setTransaction);
1432
2900
  }, [pollarClient]);
@@ -1451,59 +2919,75 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1451
2919
  });
1452
2920
  }, [pollarClient]);
1453
2921
  useEffect(() => {
2922
+ const propStyles2 = propStylesRef.current;
1454
2923
  fetchRemoteConfig(pollarClient).then((fetched) => {
1455
2924
  setRemoteConfig(fetched);
1456
2925
  setStyles({
1457
2926
  ...fetched.styles,
1458
- ...propStyles,
1459
- providers: { ...fetched.styles?.providers, ...propStyles?.providers }
2927
+ ...propStyles2,
2928
+ providers: { ...fetched.styles?.providers, ...propStyles2?.providers }
1460
2929
  });
1461
2930
  }).catch(() => {
1462
- setStyles(propStyles ?? {});
2931
+ setStyles(propStyles2 ?? {});
1463
2932
  });
1464
2933
  }, [pollarClient]);
1465
- useEffect(() => {
1466
- if (transaction.step !== "idle") {
1467
- setTransactionModalOpen(true);
1468
- }
1469
- }, [transaction.step]);
1470
2934
  const [loginModalOpen, setLoginModalOpen] = useState(false);
1471
2935
  const [transactionModalOpen, setTransactionModalOpen] = useState(false);
1472
2936
  const [kycModalOpen, setKycModalOpen] = useState(false);
1473
2937
  const [kycModalOptions, setKycModalOptions] = useState({});
1474
- const [rampWidgetOpen, setRampWidgetOpen] = useState(false);
2938
+ const [rampModalOpen, setRampModalOpen] = useState(false);
1475
2939
  const [txHistoryModalOpen, setTxHistoryModalOpen] = useState(false);
1476
2940
  const [walletBalanceModalOpen, setWalletBalanceModalOpen] = useState(false);
2941
+ const [sendModalOpen, setSendModalOpen] = useState(false);
2942
+ const [receiveModalOpen, setReceiveModalOpen] = useState(false);
2943
+ const adaptersRef = useRef(adapters);
2944
+ adaptersRef.current = adapters;
2945
+ const walletAddress = sessionState?.data?.providers?.wallet?.address || sessionState?.wallet?.publicKey || "";
2946
+ const getClient = useCallback(() => pollarClient, [pollarClient]);
2947
+ const refreshWalletBalance = useCallback(() => pollarClient.refreshBalance(walletAddress), [pollarClient, walletAddress]);
1477
2948
  const contextValue = useMemo(
1478
2949
  () => ({
1479
- walletAddress: sessionState?.data?.providers?.wallet?.address || sessionState?.wallet?.publicKey || "",
1480
- getClient: () => pollarClient,
1481
- transaction,
2950
+ // session
2951
+ walletAddress,
2952
+ isAuthenticated: !!walletAddress,
2953
+ walletType: pollarClient.getWalletType(),
2954
+ // client
2955
+ getClient,
2956
+ // auth
1482
2957
  login: (options) => pollarClient.login(options),
1483
2958
  logout: () => pollarClient.logout(),
1484
- isAuthenticated: !!sessionState?.wallet?.publicKey,
2959
+ openLoginModal: () => setLoginModalOpen(true),
2960
+ // transactions
2961
+ tx: transaction,
1485
2962
  buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
1486
2963
  signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
1487
- walletType: pollarClient.getWalletType(),
1488
- openTransactionModal: () => setTransactionModalOpen(true),
1489
- openLoginModal: () => setLoginModalOpen(true),
1490
- openKycModal: (options = {}) => {
1491
- setKycModalOptions(options);
1492
- setKycModalOpen(true);
1493
- },
1494
- openRampWidget: () => setRampWidgetOpen(true),
2964
+ openTxModal: () => setTransactionModalOpen(true),
2965
+ // tx history
1495
2966
  txHistory,
1496
2967
  openTxHistoryModal: () => setTxHistoryModalOpen(true),
1497
- openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
2968
+ // wallet balance
1498
2969
  walletBalance,
1499
- refreshBalance: (publicKey) => pollarClient.refreshBalance(publicKey),
2970
+ refreshWalletBalance,
2971
+ openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
2972
+ // send / receive
2973
+ openSendModal: () => setSendModalOpen(true),
2974
+ openReceiveModal: () => setReceiveModalOpen(true),
2975
+ // network
1500
2976
  network: networkState.step === "connected" ? networkState.network : "testnet",
1501
2977
  setNetwork: (network) => pollarClient.setNetwork(network),
1502
- config: remoteConfig,
2978
+ // kyc
2979
+ openKycModal: (options = {}) => {
2980
+ setKycModalOptions(options);
2981
+ setKycModalOpen(true);
2982
+ },
2983
+ // ramp
2984
+ openRampModal: () => setRampModalOpen(true),
2985
+ // config
2986
+ appConfig: remoteConfig,
1503
2987
  styles,
1504
- adapters
2988
+ adapters: adaptersRef.current
1505
2989
  }),
1506
- [sessionState, remoteConfig, styles, pollarClient, transaction, txHistory, networkState, walletBalance]
2990
+ [walletAddress, pollarClient, getClient, transaction, txHistory, walletBalance, refreshWalletBalance, networkState, remoteConfig, styles]
1507
2991
  );
1508
2992
  return /* @__PURE__ */ jsxs(PollarContext.Provider, { value: contextValue, children: [
1509
2993
  children,
@@ -1518,9 +3002,11 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1518
3002
  ...kycModalOptions.onApproved !== void 0 && { onApproved: kycModalOptions.onApproved }
1519
3003
  }
1520
3004
  ) }),
1521
- rampWidgetOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setRampWidgetOpen(false), children: /* @__PURE__ */ jsx(RampWidget, { onClose: () => setRampWidgetOpen(false) }) }),
3005
+ rampModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setRampModalOpen(false), children: /* @__PURE__ */ jsx(RampWidget, { onClose: () => setRampModalOpen(false) }) }),
1522
3006
  txHistoryModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setTxHistoryModalOpen(false), children: /* @__PURE__ */ jsx(TxHistoryModal, { onClose: () => setTxHistoryModalOpen(false) }) }),
1523
- walletBalanceModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) })
3007
+ walletBalanceModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) }),
3008
+ sendModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }),
3009
+ receiveModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false) }) })
1524
3010
  ] });
1525
3011
  }
1526
3012
  function usePollar() {
@@ -1566,10 +3052,13 @@ function WalletButtonTemplate({
1566
3052
  dropdownBorder,
1567
3053
  itemColor,
1568
3054
  wrapperRef,
3055
+ isInProgress,
1569
3056
  onToggleOpen,
1570
3057
  onCopy,
1571
3058
  onWalletBalance,
1572
3059
  onTxHistory,
3060
+ onSend,
3061
+ onReceive,
1573
3062
  onLogout,
1574
3063
  onLogin
1575
3064
  }) {
@@ -1580,132 +3069,129 @@ function WalletButtonTemplate({
1580
3069
  ] });
1581
3070
  }
1582
3071
  return /* @__PURE__ */ jsxs("div", { className: "wallet-wrapper", ref: wrapperRef, children: [
1583
- /* @__PURE__ */ jsxs("button", { className: "wallet-btn", style: { backgroundColor: accentColor }, onClick: onToggleOpen, children: [
1584
- cropWallet(walletAddress),
1585
- /* @__PURE__ */ jsx(
1586
- "svg",
1587
- {
1588
- className: `wallet-chevron${open ? " open" : ""}`,
1589
- viewBox: "0 0 12 12",
1590
- fill: "none",
1591
- stroke: "currentColor",
1592
- strokeWidth: "2",
1593
- strokeLinecap: "round",
1594
- strokeLinejoin: "round",
1595
- children: /* @__PURE__ */ jsx("polyline", { points: "2,4 6,8 10,4" })
1596
- }
1597
- )
1598
- ] }),
3072
+ /* @__PURE__ */ jsxs(
3073
+ "button",
3074
+ {
3075
+ className: "wallet-btn",
3076
+ style: { backgroundColor: accentColor },
3077
+ onClick: isInProgress ? void 0 : onToggleOpen,
3078
+ disabled: isInProgress,
3079
+ "aria-busy": isInProgress,
3080
+ children: [
3081
+ /* @__PURE__ */ jsx("span", { className: "wallet-btn-label", children: cropWallet(walletAddress) }),
3082
+ isInProgress ? /* @__PURE__ */ jsxs(
3083
+ "svg",
3084
+ {
3085
+ className: "wallet-btn-spinner",
3086
+ viewBox: "0 0 12 12",
3087
+ width: "12",
3088
+ height: "12",
3089
+ fill: "none",
3090
+ "aria-hidden": true,
3091
+ children: [
3092
+ /* @__PURE__ */ jsx("circle", { cx: "6", cy: "6", r: "4.5", stroke: "rgba(255,255,255,0.35)", strokeWidth: "1.5" }),
3093
+ /* @__PURE__ */ jsx(
3094
+ "circle",
3095
+ {
3096
+ cx: "6",
3097
+ cy: "6",
3098
+ r: "4.5",
3099
+ stroke: "white",
3100
+ strokeWidth: "1.5",
3101
+ strokeLinecap: "round",
3102
+ strokeDasharray: "14 9",
3103
+ transform: "rotate(-90 6 6)"
3104
+ }
3105
+ )
3106
+ ]
3107
+ }
3108
+ ) : /* @__PURE__ */ jsx(
3109
+ "svg",
3110
+ {
3111
+ className: `wallet-chevron${open ? " open" : ""}`,
3112
+ viewBox: "0 0 12 12",
3113
+ fill: "none",
3114
+ stroke: "currentColor",
3115
+ strokeWidth: "2",
3116
+ strokeLinecap: "round",
3117
+ strokeLinejoin: "round",
3118
+ children: /* @__PURE__ */ jsx("polyline", { points: "2,4 6,8 10,4" })
3119
+ }
3120
+ )
3121
+ ]
3122
+ }
3123
+ ),
1599
3124
  open && /* @__PURE__ */ jsxs("div", { className: "wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
3125
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onSend, children: [
3126
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3127
+ /* @__PURE__ */ jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
3128
+ /* @__PURE__ */ jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
3129
+ ] }),
3130
+ "Send"
3131
+ ] }),
3132
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onReceive, children: [
3133
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3134
+ /* @__PURE__ */ jsx("polyline", { points: "8 17 12 21 16 17" }),
3135
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "12", x2: "12", y2: "21" }),
3136
+ /* @__PURE__ */ jsx("path", { d: "M20.88 18.09A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.29" })
3137
+ ] }),
3138
+ "Receive"
3139
+ ] }),
3140
+ /* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
1600
3141
  /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
1601
- /* @__PURE__ */ jsxs(
1602
- "svg",
1603
- {
1604
- width: "14",
1605
- height: "14",
1606
- viewBox: "0 0 24 24",
1607
- fill: "none",
1608
- stroke: "currentColor",
1609
- strokeWidth: "2",
1610
- strokeLinecap: "round",
1611
- strokeLinejoin: "round",
1612
- children: [
1613
- /* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
1614
- /* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
1615
- ]
1616
- }
1617
- ),
3142
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3143
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
3144
+ /* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
3145
+ ] }),
1618
3146
  copied ? "Copied!" : "Copy address"
1619
3147
  ] }),
1620
- /* @__PURE__ */ jsxs(
1621
- "button",
1622
- {
1623
- className: "wallet-dropdown-item",
1624
- style: { color: itemColor },
1625
- onClick: onWalletBalance,
1626
- children: [
1627
- /* @__PURE__ */ jsxs(
1628
- "svg",
1629
- {
1630
- width: "14",
1631
- height: "14",
1632
- viewBox: "0 0 24 24",
1633
- fill: "none",
1634
- stroke: "currentColor",
1635
- strokeWidth: "2",
1636
- strokeLinecap: "round",
1637
- strokeLinejoin: "round",
1638
- children: [
1639
- /* @__PURE__ */ jsx("rect", { x: "1", y: "4", width: "22", height: "16", rx: "2", ry: "2" }),
1640
- /* @__PURE__ */ jsx("circle", { cx: "16", cy: "12", r: "2" }),
1641
- /* @__PURE__ */ jsx("path", { d: "M22 8H12" })
1642
- ]
1643
- }
1644
- ),
1645
- "Wallet balance"
1646
- ]
1647
- }
1648
- ),
1649
- /* @__PURE__ */ jsxs(
1650
- "button",
1651
- {
1652
- className: "wallet-dropdown-item",
1653
- style: { color: itemColor },
1654
- onClick: onTxHistory,
1655
- children: [
1656
- /* @__PURE__ */ jsxs(
1657
- "svg",
1658
- {
1659
- width: "14",
1660
- height: "14",
1661
- viewBox: "0 0 24 24",
1662
- fill: "none",
1663
- stroke: "currentColor",
1664
- strokeWidth: "2",
1665
- strokeLinecap: "round",
1666
- strokeLinejoin: "round",
1667
- children: [
1668
- /* @__PURE__ */ jsx("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1669
- /* @__PURE__ */ jsx("polyline", { points: "14,2 14,8 20,8" }),
1670
- /* @__PURE__ */ jsx("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
1671
- /* @__PURE__ */ jsx("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
1672
- /* @__PURE__ */ jsx("polyline", { points: "10,9 9,9 8,9" })
1673
- ]
1674
- }
1675
- ),
1676
- "Transaction history"
1677
- ]
1678
- }
1679
- ),
3148
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onWalletBalance, children: [
3149
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3150
+ /* @__PURE__ */ jsx("rect", { x: "1", y: "4", width: "22", height: "16", rx: "2", ry: "2" }),
3151
+ /* @__PURE__ */ jsx("circle", { cx: "16", cy: "12", r: "2" }),
3152
+ /* @__PURE__ */ jsx("path", { d: "M22 8H12" })
3153
+ ] }),
3154
+ "Wallet balance"
3155
+ ] }),
3156
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onTxHistory, children: [
3157
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3158
+ /* @__PURE__ */ jsx("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
3159
+ /* @__PURE__ */ jsx("polyline", { points: "14,2 14,8 20,8" }),
3160
+ /* @__PURE__ */ jsx("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
3161
+ /* @__PURE__ */ jsx("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
3162
+ /* @__PURE__ */ jsx("polyline", { points: "10,9 9,9 8,9" })
3163
+ ] }),
3164
+ "Transaction history"
3165
+ ] }),
3166
+ /* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
1680
3167
  /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
1681
- /* @__PURE__ */ jsxs(
1682
- "svg",
1683
- {
1684
- width: "14",
1685
- height: "14",
1686
- viewBox: "0 0 24 24",
1687
- fill: "none",
1688
- stroke: "currentColor",
1689
- strokeWidth: "2",
1690
- strokeLinecap: "round",
1691
- strokeLinejoin: "round",
1692
- children: [
1693
- /* @__PURE__ */ jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
1694
- /* @__PURE__ */ jsx("polyline", { points: "16,17 21,12 16,7" }),
1695
- /* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
1696
- ]
1697
- }
1698
- ),
3168
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3169
+ /* @__PURE__ */ jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
3170
+ /* @__PURE__ */ jsx("polyline", { points: "16,17 21,12 16,7" }),
3171
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
3172
+ ] }),
1699
3173
  "Log out"
1700
3174
  ] })
1701
3175
  ] })
1702
3176
  ] });
1703
3177
  }
1704
3178
  function WalletButton() {
1705
- const { getClient, walletAddress, styles, openLoginModal, openTxHistoryModal, openWalletBalanceModal } = usePollar();
3179
+ const {
3180
+ getClient,
3181
+ walletAddress,
3182
+ styles,
3183
+ openLoginModal,
3184
+ openTxHistoryModal,
3185
+ openWalletBalanceModal,
3186
+ openSendModal,
3187
+ openReceiveModal,
3188
+ tx: transaction,
3189
+ walletType
3190
+ } = usePollar();
1706
3191
  const [open, setOpen] = useState(false);
1707
3192
  const [copied, setCopied] = useState(false);
1708
3193
  const wrapperRef = useRef(null);
3194
+ const isInProgress = transaction.step === "building" || transaction.step === "signing";
1709
3195
  const { theme = "light", accentColor = "#005DB4" } = styles;
1710
3196
  const isDark = theme === "dark";
1711
3197
  const dropdownBg = isDark ? "#18181b" : "#fff";
@@ -1738,6 +3224,14 @@ function WalletButton() {
1738
3224
  setOpen(false);
1739
3225
  openTxHistoryModal();
1740
3226
  }
3227
+ function handleSend() {
3228
+ setOpen(false);
3229
+ openSendModal();
3230
+ }
3231
+ function handleReceive() {
3232
+ setOpen(false);
3233
+ openReceiveModal();
3234
+ }
1741
3235
  return /* @__PURE__ */ jsx(
1742
3236
  WalletButtonTemplate,
1743
3237
  {
@@ -1749,16 +3243,20 @@ function WalletButton() {
1749
3243
  dropdownBorder,
1750
3244
  itemColor,
1751
3245
  wrapperRef,
3246
+ isInProgress,
3247
+ walletType,
1752
3248
  onToggleOpen: () => setOpen((v) => !v),
1753
3249
  onCopy: handleCopy,
1754
3250
  onWalletBalance: handleWalletBalance,
1755
3251
  onTxHistory: handleTxHistory,
3252
+ onSend: handleSend,
3253
+ onReceive: handleReceive,
1756
3254
  onLogout: handleLogout,
1757
3255
  onLogin: openLoginModal
1758
3256
  }
1759
3257
  );
1760
3258
  }
1761
3259
 
1762
- export { KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, RampWidget, RampWidgetTemplate, RouteDisplay, TransactionModalTemplate, TxHistoryModalTemplate, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, createPollarAdapterHook, usePollar };
3260
+ export { KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, RouteDisplay, SendModal, SendModalTemplate, TransactionModalTemplate, TxHistoryModalTemplate, TxStatusView, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, createPollarAdapterHook, usePollar };
1763
3261
  //# sourceMappingURL=index.mjs.map
1764
3262
  //# sourceMappingURL=index.mjs.map