@pollar/react 0.5.3 → 0.7.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.js CHANGED
@@ -5,7 +5,999 @@ var core = require('@pollar/core');
5
5
  var react = require('react');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
 
8
- // src/context.tsx
8
+ var __create = Object.create;
9
+ var __defProp = Object.defineProperty;
10
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
+ var __getOwnPropNames = Object.getOwnPropertyNames;
12
+ var __getProtoOf = Object.getPrototypeOf;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __commonJS = (cb, mod) => function __require() {
15
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
+ mod
32
+ ));
33
+
34
+ // ../../node_modules/qr.js/lib/ErrorCorrectLevel.js
35
+ var require_ErrorCorrectLevel = __commonJS({
36
+ "../../node_modules/qr.js/lib/ErrorCorrectLevel.js"(exports$1, module) {
37
+ module.exports = {
38
+ L: 1,
39
+ M: 0,
40
+ Q: 3,
41
+ H: 2
42
+ };
43
+ }
44
+ });
45
+
46
+ // ../../node_modules/qr.js/lib/mode.js
47
+ var require_mode = __commonJS({
48
+ "../../node_modules/qr.js/lib/mode.js"(exports$1, module) {
49
+ module.exports = {
50
+ MODE_NUMBER: 1 << 0,
51
+ MODE_ALPHA_NUM: 1 << 1,
52
+ MODE_8BIT_BYTE: 1 << 2,
53
+ MODE_KANJI: 1 << 3
54
+ };
55
+ }
56
+ });
57
+
58
+ // ../../node_modules/qr.js/lib/8BitByte.js
59
+ var require_BitByte = __commonJS({
60
+ "../../node_modules/qr.js/lib/8BitByte.js"(exports$1, module) {
61
+ var mode = require_mode();
62
+ function QR8bitByte(data) {
63
+ this.mode = mode.MODE_8BIT_BYTE;
64
+ this.data = data;
65
+ }
66
+ QR8bitByte.prototype = {
67
+ getLength: function(buffer) {
68
+ return this.data.length;
69
+ },
70
+ write: function(buffer) {
71
+ for (var i = 0; i < this.data.length; i++) {
72
+ buffer.put(this.data.charCodeAt(i), 8);
73
+ }
74
+ }
75
+ };
76
+ module.exports = QR8bitByte;
77
+ }
78
+ });
79
+
80
+ // ../../node_modules/qr.js/lib/RSBlock.js
81
+ var require_RSBlock = __commonJS({
82
+ "../../node_modules/qr.js/lib/RSBlock.js"(exports$1, module) {
83
+ var ECL = require_ErrorCorrectLevel();
84
+ function QRRSBlock(totalCount, dataCount) {
85
+ this.totalCount = totalCount;
86
+ this.dataCount = dataCount;
87
+ }
88
+ QRRSBlock.RS_BLOCK_TABLE = [
89
+ // L
90
+ // M
91
+ // Q
92
+ // H
93
+ // 1
94
+ [1, 26, 19],
95
+ [1, 26, 16],
96
+ [1, 26, 13],
97
+ [1, 26, 9],
98
+ // 2
99
+ [1, 44, 34],
100
+ [1, 44, 28],
101
+ [1, 44, 22],
102
+ [1, 44, 16],
103
+ // 3
104
+ [1, 70, 55],
105
+ [1, 70, 44],
106
+ [2, 35, 17],
107
+ [2, 35, 13],
108
+ // 4
109
+ [1, 100, 80],
110
+ [2, 50, 32],
111
+ [2, 50, 24],
112
+ [4, 25, 9],
113
+ // 5
114
+ [1, 134, 108],
115
+ [2, 67, 43],
116
+ [2, 33, 15, 2, 34, 16],
117
+ [2, 33, 11, 2, 34, 12],
118
+ // 6
119
+ [2, 86, 68],
120
+ [4, 43, 27],
121
+ [4, 43, 19],
122
+ [4, 43, 15],
123
+ // 7
124
+ [2, 98, 78],
125
+ [4, 49, 31],
126
+ [2, 32, 14, 4, 33, 15],
127
+ [4, 39, 13, 1, 40, 14],
128
+ // 8
129
+ [2, 121, 97],
130
+ [2, 60, 38, 2, 61, 39],
131
+ [4, 40, 18, 2, 41, 19],
132
+ [4, 40, 14, 2, 41, 15],
133
+ // 9
134
+ [2, 146, 116],
135
+ [3, 58, 36, 2, 59, 37],
136
+ [4, 36, 16, 4, 37, 17],
137
+ [4, 36, 12, 4, 37, 13],
138
+ // 10
139
+ [2, 86, 68, 2, 87, 69],
140
+ [4, 69, 43, 1, 70, 44],
141
+ [6, 43, 19, 2, 44, 20],
142
+ [6, 43, 15, 2, 44, 16],
143
+ // 11
144
+ [4, 101, 81],
145
+ [1, 80, 50, 4, 81, 51],
146
+ [4, 50, 22, 4, 51, 23],
147
+ [3, 36, 12, 8, 37, 13],
148
+ // 12
149
+ [2, 116, 92, 2, 117, 93],
150
+ [6, 58, 36, 2, 59, 37],
151
+ [4, 46, 20, 6, 47, 21],
152
+ [7, 42, 14, 4, 43, 15],
153
+ // 13
154
+ [4, 133, 107],
155
+ [8, 59, 37, 1, 60, 38],
156
+ [8, 44, 20, 4, 45, 21],
157
+ [12, 33, 11, 4, 34, 12],
158
+ // 14
159
+ [3, 145, 115, 1, 146, 116],
160
+ [4, 64, 40, 5, 65, 41],
161
+ [11, 36, 16, 5, 37, 17],
162
+ [11, 36, 12, 5, 37, 13],
163
+ // 15
164
+ [5, 109, 87, 1, 110, 88],
165
+ [5, 65, 41, 5, 66, 42],
166
+ [5, 54, 24, 7, 55, 25],
167
+ [11, 36, 12],
168
+ // 16
169
+ [5, 122, 98, 1, 123, 99],
170
+ [7, 73, 45, 3, 74, 46],
171
+ [15, 43, 19, 2, 44, 20],
172
+ [3, 45, 15, 13, 46, 16],
173
+ // 17
174
+ [1, 135, 107, 5, 136, 108],
175
+ [10, 74, 46, 1, 75, 47],
176
+ [1, 50, 22, 15, 51, 23],
177
+ [2, 42, 14, 17, 43, 15],
178
+ // 18
179
+ [5, 150, 120, 1, 151, 121],
180
+ [9, 69, 43, 4, 70, 44],
181
+ [17, 50, 22, 1, 51, 23],
182
+ [2, 42, 14, 19, 43, 15],
183
+ // 19
184
+ [3, 141, 113, 4, 142, 114],
185
+ [3, 70, 44, 11, 71, 45],
186
+ [17, 47, 21, 4, 48, 22],
187
+ [9, 39, 13, 16, 40, 14],
188
+ // 20
189
+ [3, 135, 107, 5, 136, 108],
190
+ [3, 67, 41, 13, 68, 42],
191
+ [15, 54, 24, 5, 55, 25],
192
+ [15, 43, 15, 10, 44, 16],
193
+ // 21
194
+ [4, 144, 116, 4, 145, 117],
195
+ [17, 68, 42],
196
+ [17, 50, 22, 6, 51, 23],
197
+ [19, 46, 16, 6, 47, 17],
198
+ // 22
199
+ [2, 139, 111, 7, 140, 112],
200
+ [17, 74, 46],
201
+ [7, 54, 24, 16, 55, 25],
202
+ [34, 37, 13],
203
+ // 23
204
+ [4, 151, 121, 5, 152, 122],
205
+ [4, 75, 47, 14, 76, 48],
206
+ [11, 54, 24, 14, 55, 25],
207
+ [16, 45, 15, 14, 46, 16],
208
+ // 24
209
+ [6, 147, 117, 4, 148, 118],
210
+ [6, 73, 45, 14, 74, 46],
211
+ [11, 54, 24, 16, 55, 25],
212
+ [30, 46, 16, 2, 47, 17],
213
+ // 25
214
+ [8, 132, 106, 4, 133, 107],
215
+ [8, 75, 47, 13, 76, 48],
216
+ [7, 54, 24, 22, 55, 25],
217
+ [22, 45, 15, 13, 46, 16],
218
+ // 26
219
+ [10, 142, 114, 2, 143, 115],
220
+ [19, 74, 46, 4, 75, 47],
221
+ [28, 50, 22, 6, 51, 23],
222
+ [33, 46, 16, 4, 47, 17],
223
+ // 27
224
+ [8, 152, 122, 4, 153, 123],
225
+ [22, 73, 45, 3, 74, 46],
226
+ [8, 53, 23, 26, 54, 24],
227
+ [12, 45, 15, 28, 46, 16],
228
+ // 28
229
+ [3, 147, 117, 10, 148, 118],
230
+ [3, 73, 45, 23, 74, 46],
231
+ [4, 54, 24, 31, 55, 25],
232
+ [11, 45, 15, 31, 46, 16],
233
+ // 29
234
+ [7, 146, 116, 7, 147, 117],
235
+ [21, 73, 45, 7, 74, 46],
236
+ [1, 53, 23, 37, 54, 24],
237
+ [19, 45, 15, 26, 46, 16],
238
+ // 30
239
+ [5, 145, 115, 10, 146, 116],
240
+ [19, 75, 47, 10, 76, 48],
241
+ [15, 54, 24, 25, 55, 25],
242
+ [23, 45, 15, 25, 46, 16],
243
+ // 31
244
+ [13, 145, 115, 3, 146, 116],
245
+ [2, 74, 46, 29, 75, 47],
246
+ [42, 54, 24, 1, 55, 25],
247
+ [23, 45, 15, 28, 46, 16],
248
+ // 32
249
+ [17, 145, 115],
250
+ [10, 74, 46, 23, 75, 47],
251
+ [10, 54, 24, 35, 55, 25],
252
+ [19, 45, 15, 35, 46, 16],
253
+ // 33
254
+ [17, 145, 115, 1, 146, 116],
255
+ [14, 74, 46, 21, 75, 47],
256
+ [29, 54, 24, 19, 55, 25],
257
+ [11, 45, 15, 46, 46, 16],
258
+ // 34
259
+ [13, 145, 115, 6, 146, 116],
260
+ [14, 74, 46, 23, 75, 47],
261
+ [44, 54, 24, 7, 55, 25],
262
+ [59, 46, 16, 1, 47, 17],
263
+ // 35
264
+ [12, 151, 121, 7, 152, 122],
265
+ [12, 75, 47, 26, 76, 48],
266
+ [39, 54, 24, 14, 55, 25],
267
+ [22, 45, 15, 41, 46, 16],
268
+ // 36
269
+ [6, 151, 121, 14, 152, 122],
270
+ [6, 75, 47, 34, 76, 48],
271
+ [46, 54, 24, 10, 55, 25],
272
+ [2, 45, 15, 64, 46, 16],
273
+ // 37
274
+ [17, 152, 122, 4, 153, 123],
275
+ [29, 74, 46, 14, 75, 47],
276
+ [49, 54, 24, 10, 55, 25],
277
+ [24, 45, 15, 46, 46, 16],
278
+ // 38
279
+ [4, 152, 122, 18, 153, 123],
280
+ [13, 74, 46, 32, 75, 47],
281
+ [48, 54, 24, 14, 55, 25],
282
+ [42, 45, 15, 32, 46, 16],
283
+ // 39
284
+ [20, 147, 117, 4, 148, 118],
285
+ [40, 75, 47, 7, 76, 48],
286
+ [43, 54, 24, 22, 55, 25],
287
+ [10, 45, 15, 67, 46, 16],
288
+ // 40
289
+ [19, 148, 118, 6, 149, 119],
290
+ [18, 75, 47, 31, 76, 48],
291
+ [34, 54, 24, 34, 55, 25],
292
+ [20, 45, 15, 61, 46, 16]
293
+ ];
294
+ QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
295
+ var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
296
+ if (rsBlock == void 0) {
297
+ throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
298
+ }
299
+ var length = rsBlock.length / 3;
300
+ var list = new Array();
301
+ for (var i = 0; i < length; i++) {
302
+ var count = rsBlock[i * 3 + 0];
303
+ var totalCount = rsBlock[i * 3 + 1];
304
+ var dataCount = rsBlock[i * 3 + 2];
305
+ for (var j = 0; j < count; j++) {
306
+ list.push(new QRRSBlock(totalCount, dataCount));
307
+ }
308
+ }
309
+ return list;
310
+ };
311
+ QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
312
+ switch (errorCorrectLevel) {
313
+ case ECL.L:
314
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
315
+ case ECL.M:
316
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
317
+ case ECL.Q:
318
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
319
+ case ECL.H:
320
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
321
+ default:
322
+ return void 0;
323
+ }
324
+ };
325
+ module.exports = QRRSBlock;
326
+ }
327
+ });
328
+
329
+ // ../../node_modules/qr.js/lib/BitBuffer.js
330
+ var require_BitBuffer = __commonJS({
331
+ "../../node_modules/qr.js/lib/BitBuffer.js"(exports$1, module) {
332
+ function QRBitBuffer() {
333
+ this.buffer = new Array();
334
+ this.length = 0;
335
+ }
336
+ QRBitBuffer.prototype = {
337
+ get: function(index) {
338
+ var bufIndex = Math.floor(index / 8);
339
+ return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
340
+ },
341
+ put: function(num, length) {
342
+ for (var i = 0; i < length; i++) {
343
+ this.putBit((num >>> length - i - 1 & 1) == 1);
344
+ }
345
+ },
346
+ getLengthInBits: function() {
347
+ return this.length;
348
+ },
349
+ putBit: function(bit) {
350
+ var bufIndex = Math.floor(this.length / 8);
351
+ if (this.buffer.length <= bufIndex) {
352
+ this.buffer.push(0);
353
+ }
354
+ if (bit) {
355
+ this.buffer[bufIndex] |= 128 >>> this.length % 8;
356
+ }
357
+ this.length++;
358
+ }
359
+ };
360
+ module.exports = QRBitBuffer;
361
+ }
362
+ });
363
+
364
+ // ../../node_modules/qr.js/lib/math.js
365
+ var require_math = __commonJS({
366
+ "../../node_modules/qr.js/lib/math.js"(exports$1, module) {
367
+ var QRMath = {
368
+ glog: function(n) {
369
+ if (n < 1) {
370
+ throw new Error("glog(" + n + ")");
371
+ }
372
+ return QRMath.LOG_TABLE[n];
373
+ },
374
+ gexp: function(n) {
375
+ while (n < 0) {
376
+ n += 255;
377
+ }
378
+ while (n >= 256) {
379
+ n -= 255;
380
+ }
381
+ return QRMath.EXP_TABLE[n];
382
+ },
383
+ EXP_TABLE: new Array(256),
384
+ LOG_TABLE: new Array(256)
385
+ };
386
+ for (i = 0; i < 8; i++) {
387
+ QRMath.EXP_TABLE[i] = 1 << i;
388
+ }
389
+ var i;
390
+ for (i = 8; i < 256; i++) {
391
+ QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
392
+ }
393
+ var i;
394
+ for (i = 0; i < 255; i++) {
395
+ QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
396
+ }
397
+ var i;
398
+ module.exports = QRMath;
399
+ }
400
+ });
401
+
402
+ // ../../node_modules/qr.js/lib/Polynomial.js
403
+ var require_Polynomial = __commonJS({
404
+ "../../node_modules/qr.js/lib/Polynomial.js"(exports$1, module) {
405
+ var math = require_math();
406
+ function QRPolynomial(num, shift) {
407
+ if (num.length == void 0) {
408
+ throw new Error(num.length + "/" + shift);
409
+ }
410
+ var offset = 0;
411
+ while (offset < num.length && num[offset] == 0) {
412
+ offset++;
413
+ }
414
+ this.num = new Array(num.length - offset + shift);
415
+ for (var i = 0; i < num.length - offset; i++) {
416
+ this.num[i] = num[i + offset];
417
+ }
418
+ }
419
+ QRPolynomial.prototype = {
420
+ get: function(index) {
421
+ return this.num[index];
422
+ },
423
+ getLength: function() {
424
+ return this.num.length;
425
+ },
426
+ multiply: function(e) {
427
+ var num = new Array(this.getLength() + e.getLength() - 1);
428
+ for (var i = 0; i < this.getLength(); i++) {
429
+ for (var j = 0; j < e.getLength(); j++) {
430
+ num[i + j] ^= math.gexp(math.glog(this.get(i)) + math.glog(e.get(j)));
431
+ }
432
+ }
433
+ return new QRPolynomial(num, 0);
434
+ },
435
+ mod: function(e) {
436
+ if (this.getLength() - e.getLength() < 0) {
437
+ return this;
438
+ }
439
+ var ratio = math.glog(this.get(0)) - math.glog(e.get(0));
440
+ var num = new Array(this.getLength());
441
+ for (var i = 0; i < this.getLength(); i++) {
442
+ num[i] = this.get(i);
443
+ }
444
+ for (var i = 0; i < e.getLength(); i++) {
445
+ num[i] ^= math.gexp(math.glog(e.get(i)) + ratio);
446
+ }
447
+ return new QRPolynomial(num, 0).mod(e);
448
+ }
449
+ };
450
+ module.exports = QRPolynomial;
451
+ }
452
+ });
453
+
454
+ // ../../node_modules/qr.js/lib/util.js
455
+ var require_util = __commonJS({
456
+ "../../node_modules/qr.js/lib/util.js"(exports$1, module) {
457
+ var Mode = require_mode();
458
+ var Polynomial = require_Polynomial();
459
+ var math = require_math();
460
+ var QRMaskPattern = {
461
+ PATTERN000: 0,
462
+ PATTERN001: 1,
463
+ PATTERN010: 2,
464
+ PATTERN011: 3,
465
+ PATTERN100: 4,
466
+ PATTERN101: 5,
467
+ PATTERN110: 6,
468
+ PATTERN111: 7
469
+ };
470
+ var QRUtil = {
471
+ PATTERN_POSITION_TABLE: [
472
+ [],
473
+ [6, 18],
474
+ [6, 22],
475
+ [6, 26],
476
+ [6, 30],
477
+ [6, 34],
478
+ [6, 22, 38],
479
+ [6, 24, 42],
480
+ [6, 26, 46],
481
+ [6, 28, 50],
482
+ [6, 30, 54],
483
+ [6, 32, 58],
484
+ [6, 34, 62],
485
+ [6, 26, 46, 66],
486
+ [6, 26, 48, 70],
487
+ [6, 26, 50, 74],
488
+ [6, 30, 54, 78],
489
+ [6, 30, 56, 82],
490
+ [6, 30, 58, 86],
491
+ [6, 34, 62, 90],
492
+ [6, 28, 50, 72, 94],
493
+ [6, 26, 50, 74, 98],
494
+ [6, 30, 54, 78, 102],
495
+ [6, 28, 54, 80, 106],
496
+ [6, 32, 58, 84, 110],
497
+ [6, 30, 58, 86, 114],
498
+ [6, 34, 62, 90, 118],
499
+ [6, 26, 50, 74, 98, 122],
500
+ [6, 30, 54, 78, 102, 126],
501
+ [6, 26, 52, 78, 104, 130],
502
+ [6, 30, 56, 82, 108, 134],
503
+ [6, 34, 60, 86, 112, 138],
504
+ [6, 30, 58, 86, 114, 142],
505
+ [6, 34, 62, 90, 118, 146],
506
+ [6, 30, 54, 78, 102, 126, 150],
507
+ [6, 24, 50, 76, 102, 128, 154],
508
+ [6, 28, 54, 80, 106, 132, 158],
509
+ [6, 32, 58, 84, 110, 136, 162],
510
+ [6, 26, 54, 82, 110, 138, 166],
511
+ [6, 30, 58, 86, 114, 142, 170]
512
+ ],
513
+ G15: 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0,
514
+ G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0,
515
+ G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1,
516
+ getBCHTypeInfo: function(data) {
517
+ var d = data << 10;
518
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
519
+ d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15);
520
+ }
521
+ return (data << 10 | d) ^ QRUtil.G15_MASK;
522
+ },
523
+ getBCHTypeNumber: function(data) {
524
+ var d = data << 12;
525
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
526
+ d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);
527
+ }
528
+ return data << 12 | d;
529
+ },
530
+ getBCHDigit: function(data) {
531
+ var digit = 0;
532
+ while (data != 0) {
533
+ digit++;
534
+ data >>>= 1;
535
+ }
536
+ return digit;
537
+ },
538
+ getPatternPosition: function(typeNumber) {
539
+ return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
540
+ },
541
+ getMask: function(maskPattern, i, j) {
542
+ switch (maskPattern) {
543
+ case QRMaskPattern.PATTERN000:
544
+ return (i + j) % 2 == 0;
545
+ case QRMaskPattern.PATTERN001:
546
+ return i % 2 == 0;
547
+ case QRMaskPattern.PATTERN010:
548
+ return j % 3 == 0;
549
+ case QRMaskPattern.PATTERN011:
550
+ return (i + j) % 3 == 0;
551
+ case QRMaskPattern.PATTERN100:
552
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
553
+ case QRMaskPattern.PATTERN101:
554
+ return i * j % 2 + i * j % 3 == 0;
555
+ case QRMaskPattern.PATTERN110:
556
+ return (i * j % 2 + i * j % 3) % 2 == 0;
557
+ case QRMaskPattern.PATTERN111:
558
+ return (i * j % 3 + (i + j) % 2) % 2 == 0;
559
+ default:
560
+ throw new Error("bad maskPattern:" + maskPattern);
561
+ }
562
+ },
563
+ getErrorCorrectPolynomial: function(errorCorrectLength) {
564
+ var a = new Polynomial([1], 0);
565
+ for (var i = 0; i < errorCorrectLength; i++) {
566
+ a = a.multiply(new Polynomial([1, math.gexp(i)], 0));
567
+ }
568
+ return a;
569
+ },
570
+ getLengthInBits: function(mode, type) {
571
+ if (1 <= type && type < 10) {
572
+ switch (mode) {
573
+ case Mode.MODE_NUMBER:
574
+ return 10;
575
+ case Mode.MODE_ALPHA_NUM:
576
+ return 9;
577
+ case Mode.MODE_8BIT_BYTE:
578
+ return 8;
579
+ case Mode.MODE_KANJI:
580
+ return 8;
581
+ default:
582
+ throw new Error("mode:" + mode);
583
+ }
584
+ } else if (type < 27) {
585
+ switch (mode) {
586
+ case Mode.MODE_NUMBER:
587
+ return 12;
588
+ case Mode.MODE_ALPHA_NUM:
589
+ return 11;
590
+ case Mode.MODE_8BIT_BYTE:
591
+ return 16;
592
+ case Mode.MODE_KANJI:
593
+ return 10;
594
+ default:
595
+ throw new Error("mode:" + mode);
596
+ }
597
+ } else if (type < 41) {
598
+ switch (mode) {
599
+ case Mode.MODE_NUMBER:
600
+ return 14;
601
+ case Mode.MODE_ALPHA_NUM:
602
+ return 13;
603
+ case Mode.MODE_8BIT_BYTE:
604
+ return 16;
605
+ case Mode.MODE_KANJI:
606
+ return 12;
607
+ default:
608
+ throw new Error("mode:" + mode);
609
+ }
610
+ } else {
611
+ throw new Error("type:" + type);
612
+ }
613
+ },
614
+ getLostPoint: function(qrCode) {
615
+ var moduleCount = qrCode.getModuleCount();
616
+ var lostPoint = 0;
617
+ for (var row = 0; row < moduleCount; row++) {
618
+ for (var col = 0; col < moduleCount; col++) {
619
+ var sameCount = 0;
620
+ var dark = qrCode.isDark(row, col);
621
+ for (var r = -1; r <= 1; r++) {
622
+ if (row + r < 0 || moduleCount <= row + r) {
623
+ continue;
624
+ }
625
+ for (var c = -1; c <= 1; c++) {
626
+ if (col + c < 0 || moduleCount <= col + c) {
627
+ continue;
628
+ }
629
+ if (r == 0 && c == 0) {
630
+ continue;
631
+ }
632
+ if (dark == qrCode.isDark(row + r, col + c)) {
633
+ sameCount++;
634
+ }
635
+ }
636
+ }
637
+ if (sameCount > 5) {
638
+ lostPoint += 3 + sameCount - 5;
639
+ }
640
+ }
641
+ }
642
+ for (var row = 0; row < moduleCount - 1; row++) {
643
+ for (var col = 0; col < moduleCount - 1; col++) {
644
+ var count = 0;
645
+ if (qrCode.isDark(row, col)) count++;
646
+ if (qrCode.isDark(row + 1, col)) count++;
647
+ if (qrCode.isDark(row, col + 1)) count++;
648
+ if (qrCode.isDark(row + 1, col + 1)) count++;
649
+ if (count == 0 || count == 4) {
650
+ lostPoint += 3;
651
+ }
652
+ }
653
+ }
654
+ for (var row = 0; row < moduleCount; row++) {
655
+ for (var col = 0; col < moduleCount - 6; col++) {
656
+ 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)) {
657
+ lostPoint += 40;
658
+ }
659
+ }
660
+ }
661
+ for (var col = 0; col < moduleCount; col++) {
662
+ for (var row = 0; row < moduleCount - 6; row++) {
663
+ 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)) {
664
+ lostPoint += 40;
665
+ }
666
+ }
667
+ }
668
+ var darkCount = 0;
669
+ for (var col = 0; col < moduleCount; col++) {
670
+ for (var row = 0; row < moduleCount; row++) {
671
+ if (qrCode.isDark(row, col)) {
672
+ darkCount++;
673
+ }
674
+ }
675
+ }
676
+ var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
677
+ lostPoint += ratio * 10;
678
+ return lostPoint;
679
+ }
680
+ };
681
+ module.exports = QRUtil;
682
+ }
683
+ });
684
+
685
+ // ../../node_modules/qr.js/lib/QRCode.js
686
+ var require_QRCode = __commonJS({
687
+ "../../node_modules/qr.js/lib/QRCode.js"(exports$1, module) {
688
+ var BitByte = require_BitByte();
689
+ var RSBlock = require_RSBlock();
690
+ var BitBuffer = require_BitBuffer();
691
+ var util = require_util();
692
+ var Polynomial = require_Polynomial();
693
+ function QRCode3(typeNumber, errorCorrectLevel) {
694
+ this.typeNumber = typeNumber;
695
+ this.errorCorrectLevel = errorCorrectLevel;
696
+ this.modules = null;
697
+ this.moduleCount = 0;
698
+ this.dataCache = null;
699
+ this.dataList = [];
700
+ }
701
+ var proto = QRCode3.prototype;
702
+ proto.addData = function(data) {
703
+ var newData = new BitByte(data);
704
+ this.dataList.push(newData);
705
+ this.dataCache = null;
706
+ };
707
+ proto.isDark = function(row, col) {
708
+ if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
709
+ throw new Error(row + "," + col);
710
+ }
711
+ return this.modules[row][col];
712
+ };
713
+ proto.getModuleCount = function() {
714
+ return this.moduleCount;
715
+ };
716
+ proto.make = function() {
717
+ if (this.typeNumber < 1) {
718
+ var typeNumber = 1;
719
+ for (typeNumber = 1; typeNumber < 40; typeNumber++) {
720
+ var rsBlocks = RSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
721
+ var buffer = new BitBuffer();
722
+ var totalDataCount = 0;
723
+ for (var i = 0; i < rsBlocks.length; i++) {
724
+ totalDataCount += rsBlocks[i].dataCount;
725
+ }
726
+ for (var i = 0; i < this.dataList.length; i++) {
727
+ var data = this.dataList[i];
728
+ buffer.put(data.mode, 4);
729
+ buffer.put(data.getLength(), util.getLengthInBits(data.mode, typeNumber));
730
+ data.write(buffer);
731
+ }
732
+ if (buffer.getLengthInBits() <= totalDataCount * 8)
733
+ break;
734
+ }
735
+ this.typeNumber = typeNumber;
736
+ }
737
+ this.makeImpl(false, this.getBestMaskPattern());
738
+ };
739
+ proto.makeImpl = function(test, maskPattern) {
740
+ this.moduleCount = this.typeNumber * 4 + 17;
741
+ this.modules = new Array(this.moduleCount);
742
+ for (var row = 0; row < this.moduleCount; row++) {
743
+ this.modules[row] = new Array(this.moduleCount);
744
+ for (var col = 0; col < this.moduleCount; col++) {
745
+ this.modules[row][col] = null;
746
+ }
747
+ }
748
+ this.setupPositionProbePattern(0, 0);
749
+ this.setupPositionProbePattern(this.moduleCount - 7, 0);
750
+ this.setupPositionProbePattern(0, this.moduleCount - 7);
751
+ this.setupPositionAdjustPattern();
752
+ this.setupTimingPattern();
753
+ this.setupTypeInfo(test, maskPattern);
754
+ if (this.typeNumber >= 7) {
755
+ this.setupTypeNumber(test);
756
+ }
757
+ if (this.dataCache == null) {
758
+ this.dataCache = QRCode3.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
759
+ }
760
+ this.mapData(this.dataCache, maskPattern);
761
+ };
762
+ proto.setupPositionProbePattern = function(row, col) {
763
+ for (var r = -1; r <= 7; r++) {
764
+ if (row + r <= -1 || this.moduleCount <= row + r) continue;
765
+ for (var c = -1; c <= 7; c++) {
766
+ if (col + c <= -1 || this.moduleCount <= col + c) continue;
767
+ 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) {
768
+ this.modules[row + r][col + c] = true;
769
+ } else {
770
+ this.modules[row + r][col + c] = false;
771
+ }
772
+ }
773
+ }
774
+ };
775
+ proto.getBestMaskPattern = function() {
776
+ var minLostPoint = 0;
777
+ var pattern = 0;
778
+ for (var i = 0; i < 8; i++) {
779
+ this.makeImpl(true, i);
780
+ var lostPoint = util.getLostPoint(this);
781
+ if (i == 0 || minLostPoint > lostPoint) {
782
+ minLostPoint = lostPoint;
783
+ pattern = i;
784
+ }
785
+ }
786
+ return pattern;
787
+ };
788
+ proto.createMovieClip = function(target_mc, instance_name, depth) {
789
+ var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
790
+ var cs = 1;
791
+ this.make();
792
+ for (var row = 0; row < this.modules.length; row++) {
793
+ var y = row * cs;
794
+ for (var col = 0; col < this.modules[row].length; col++) {
795
+ var x = col * cs;
796
+ var dark = this.modules[row][col];
797
+ if (dark) {
798
+ qr_mc.beginFill(0, 100);
799
+ qr_mc.moveTo(x, y);
800
+ qr_mc.lineTo(x + cs, y);
801
+ qr_mc.lineTo(x + cs, y + cs);
802
+ qr_mc.lineTo(x, y + cs);
803
+ qr_mc.endFill();
804
+ }
805
+ }
806
+ }
807
+ return qr_mc;
808
+ };
809
+ proto.setupTimingPattern = function() {
810
+ for (var r = 8; r < this.moduleCount - 8; r++) {
811
+ if (this.modules[r][6] != null) {
812
+ continue;
813
+ }
814
+ this.modules[r][6] = r % 2 == 0;
815
+ }
816
+ for (var c = 8; c < this.moduleCount - 8; c++) {
817
+ if (this.modules[6][c] != null) {
818
+ continue;
819
+ }
820
+ this.modules[6][c] = c % 2 == 0;
821
+ }
822
+ };
823
+ proto.setupPositionAdjustPattern = function() {
824
+ var pos = util.getPatternPosition(this.typeNumber);
825
+ for (var i = 0; i < pos.length; i++) {
826
+ for (var j = 0; j < pos.length; j++) {
827
+ var row = pos[i];
828
+ var col = pos[j];
829
+ if (this.modules[row][col] != null) {
830
+ continue;
831
+ }
832
+ for (var r = -2; r <= 2; r++) {
833
+ for (var c = -2; c <= 2; c++) {
834
+ if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) {
835
+ this.modules[row + r][col + c] = true;
836
+ } else {
837
+ this.modules[row + r][col + c] = false;
838
+ }
839
+ }
840
+ }
841
+ }
842
+ }
843
+ };
844
+ proto.setupTypeNumber = function(test) {
845
+ var bits = util.getBCHTypeNumber(this.typeNumber);
846
+ for (var i = 0; i < 18; i++) {
847
+ var mod = !test && (bits >> i & 1) == 1;
848
+ this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
849
+ }
850
+ for (var i = 0; i < 18; i++) {
851
+ var mod = !test && (bits >> i & 1) == 1;
852
+ this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
853
+ }
854
+ };
855
+ proto.setupTypeInfo = function(test, maskPattern) {
856
+ var data = this.errorCorrectLevel << 3 | maskPattern;
857
+ var bits = util.getBCHTypeInfo(data);
858
+ for (var i = 0; i < 15; i++) {
859
+ var mod = !test && (bits >> i & 1) == 1;
860
+ if (i < 6) {
861
+ this.modules[i][8] = mod;
862
+ } else if (i < 8) {
863
+ this.modules[i + 1][8] = mod;
864
+ } else {
865
+ this.modules[this.moduleCount - 15 + i][8] = mod;
866
+ }
867
+ }
868
+ for (var i = 0; i < 15; i++) {
869
+ var mod = !test && (bits >> i & 1) == 1;
870
+ if (i < 8) {
871
+ this.modules[8][this.moduleCount - i - 1] = mod;
872
+ } else if (i < 9) {
873
+ this.modules[8][15 - i - 1 + 1] = mod;
874
+ } else {
875
+ this.modules[8][15 - i - 1] = mod;
876
+ }
877
+ }
878
+ this.modules[this.moduleCount - 8][8] = !test;
879
+ };
880
+ proto.mapData = function(data, maskPattern) {
881
+ var inc = -1;
882
+ var row = this.moduleCount - 1;
883
+ var bitIndex = 7;
884
+ var byteIndex = 0;
885
+ for (var col = this.moduleCount - 1; col > 0; col -= 2) {
886
+ if (col == 6) col--;
887
+ while (true) {
888
+ for (var c = 0; c < 2; c++) {
889
+ if (this.modules[row][col - c] == null) {
890
+ var dark = false;
891
+ if (byteIndex < data.length) {
892
+ dark = (data[byteIndex] >>> bitIndex & 1) == 1;
893
+ }
894
+ var mask = util.getMask(maskPattern, row, col - c);
895
+ if (mask) {
896
+ dark = !dark;
897
+ }
898
+ this.modules[row][col - c] = dark;
899
+ bitIndex--;
900
+ if (bitIndex == -1) {
901
+ byteIndex++;
902
+ bitIndex = 7;
903
+ }
904
+ }
905
+ }
906
+ row += inc;
907
+ if (row < 0 || this.moduleCount <= row) {
908
+ row -= inc;
909
+ inc = -inc;
910
+ break;
911
+ }
912
+ }
913
+ }
914
+ };
915
+ QRCode3.PAD0 = 236;
916
+ QRCode3.PAD1 = 17;
917
+ QRCode3.createData = function(typeNumber, errorCorrectLevel, dataList) {
918
+ var rsBlocks = RSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
919
+ var buffer = new BitBuffer();
920
+ for (var i = 0; i < dataList.length; i++) {
921
+ var data = dataList[i];
922
+ buffer.put(data.mode, 4);
923
+ buffer.put(data.getLength(), util.getLengthInBits(data.mode, typeNumber));
924
+ data.write(buffer);
925
+ }
926
+ var totalDataCount = 0;
927
+ for (var i = 0; i < rsBlocks.length; i++) {
928
+ totalDataCount += rsBlocks[i].dataCount;
929
+ }
930
+ if (buffer.getLengthInBits() > totalDataCount * 8) {
931
+ throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")");
932
+ }
933
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
934
+ buffer.put(0, 4);
935
+ }
936
+ while (buffer.getLengthInBits() % 8 != 0) {
937
+ buffer.putBit(false);
938
+ }
939
+ while (true) {
940
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
941
+ break;
942
+ }
943
+ buffer.put(QRCode3.PAD0, 8);
944
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
945
+ break;
946
+ }
947
+ buffer.put(QRCode3.PAD1, 8);
948
+ }
949
+ return QRCode3.createBytes(buffer, rsBlocks);
950
+ };
951
+ QRCode3.createBytes = function(buffer, rsBlocks) {
952
+ var offset = 0;
953
+ var maxDcCount = 0;
954
+ var maxEcCount = 0;
955
+ var dcdata = new Array(rsBlocks.length);
956
+ var ecdata = new Array(rsBlocks.length);
957
+ for (var r = 0; r < rsBlocks.length; r++) {
958
+ var dcCount = rsBlocks[r].dataCount;
959
+ var ecCount = rsBlocks[r].totalCount - dcCount;
960
+ maxDcCount = Math.max(maxDcCount, dcCount);
961
+ maxEcCount = Math.max(maxEcCount, ecCount);
962
+ dcdata[r] = new Array(dcCount);
963
+ for (var i = 0; i < dcdata[r].length; i++) {
964
+ dcdata[r][i] = 255 & buffer.buffer[i + offset];
965
+ }
966
+ offset += dcCount;
967
+ var rsPoly = util.getErrorCorrectPolynomial(ecCount);
968
+ var rawPoly = new Polynomial(dcdata[r], rsPoly.getLength() - 1);
969
+ var modPoly = rawPoly.mod(rsPoly);
970
+ ecdata[r] = new Array(rsPoly.getLength() - 1);
971
+ for (var i = 0; i < ecdata[r].length; i++) {
972
+ var modIndex = i + modPoly.getLength() - ecdata[r].length;
973
+ ecdata[r][i] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
974
+ }
975
+ }
976
+ var totalCodeCount = 0;
977
+ for (var i = 0; i < rsBlocks.length; i++) {
978
+ totalCodeCount += rsBlocks[i].totalCount;
979
+ }
980
+ var data = new Array(totalCodeCount);
981
+ var index = 0;
982
+ for (var i = 0; i < maxDcCount; i++) {
983
+ for (var r = 0; r < rsBlocks.length; r++) {
984
+ if (i < dcdata[r].length) {
985
+ data[index++] = dcdata[r][i];
986
+ }
987
+ }
988
+ }
989
+ for (var i = 0; i < maxEcCount; i++) {
990
+ for (var r = 0; r < rsBlocks.length; r++) {
991
+ if (i < ecdata[r].length) {
992
+ data[index++] = ecdata[r][i];
993
+ }
994
+ }
995
+ }
996
+ return data;
997
+ };
998
+ module.exports = QRCode3;
999
+ }
1000
+ });
9
1001
 
10
1002
  // src/constants.ts
11
1003
  var LOGO_POLLAR = "https://pollar.xyz/assets/logo_pollar.png";
@@ -38,7 +1030,7 @@ var PollarModalFooter = () => {
38
1030
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
39
1031
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-footer-version", children: [
40
1032
  "v",
41
- "0.5.3"
1033
+ "0.7.0"
42
1034
  ] })
43
1035
  ] })
44
1036
  ] });
@@ -171,8 +1163,8 @@ function KycModal({ onClose, country = "MX", level = "basic", onApproved }) {
171
1163
  const { theme = "light", accentColor = "#005DB4" } = styles;
172
1164
  react.useEffect(() => {
173
1165
  setIsLoading(true);
174
- client.getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
175
- }, [country]);
1166
+ getClient().getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
1167
+ }, [getClient, country]);
176
1168
  async function handleSelectProvider(provider) {
177
1169
  setSelectedProvider(provider);
178
1170
  setIsLoading(true);
@@ -503,10 +1495,12 @@ function LoginModalTemplate({
503
1495
  }
504
1496
  function LoginModal({ onClose }) {
505
1497
  const [email, setEmail] = react.useState("");
506
- const { getClient, styles, config } = usePollar();
1498
+ const { getClient, styles, appConfig: config } = usePollar();
507
1499
  const [authState, setAuthState] = react.useState(() => getClient().getAuthState());
508
1500
  const [codeInputKey, setCodeInputKey] = react.useState(0);
509
1501
  const pendingEmail = react.useRef(null);
1502
+ const onCloseRef = react.useRef(onClose);
1503
+ onCloseRef.current = onClose;
510
1504
  react.useEffect(() => {
511
1505
  return getClient().onAuthStateChange((next) => {
512
1506
  setAuthState(next);
@@ -518,10 +1512,10 @@ function LoginModal({ onClose }) {
518
1512
  setCodeInputKey((k) => k + 1);
519
1513
  }
520
1514
  if (next.step === "authenticated") {
521
- setTimeout(onClose, 1e3);
1515
+ setTimeout(onCloseRef.current, 1e3);
522
1516
  }
523
1517
  });
524
- }, []);
1518
+ }, [getClient]);
525
1519
  const { theme = "light", accentColor = "#005DB4", logoUrl, emailEnabled, embeddedWallets, providers } = styles;
526
1520
  function handleClose() {
527
1521
  setEmail("");
@@ -583,70 +1577,60 @@ function LoginModal({ onClose }) {
583
1577
  }
584
1578
  ) });
585
1579
  }
586
- var RAIL_LABELS = {
587
- SPEI: "SPEI (Mexico)",
588
- PIX: "PIX (Brazil)",
589
- PSE: "PSE (Colombia)",
590
- ACH: "ACH (US)"
591
- };
592
- function RouteDisplay({ quote, onSelect }) {
593
- return /* @__PURE__ */ jsxRuntime.jsxs(
594
- "div",
1580
+
1581
+ // src/lib/qr-code/index.tsx
1582
+ var import_ErrorCorrectLevel = __toESM(require_ErrorCorrectLevel());
1583
+ var import_QRCode = __toESM(require_QRCode());
1584
+ var QRCodeSvg = react.forwardRef(function QRCodeSvg2({
1585
+ bgColor,
1586
+ bgD,
1587
+ fgD,
1588
+ fgColor,
1589
+ size,
1590
+ title,
1591
+ viewBoxSize,
1592
+ xmlns = "http://www.w3.org/2000/svg",
1593
+ ...props
1594
+ }, ref) {
1595
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { ...props, height: size, ref, viewBox: `0 0 ${viewBoxSize} ${viewBoxSize}`, width: size, xmlns, children: [
1596
+ title ? /* @__PURE__ */ jsxRuntime.jsx("title", { children: title }) : null,
1597
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: bgD, fill: bgColor }),
1598
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: fgD, fill: fgColor })
1599
+ ] });
1600
+ });
1601
+ QRCodeSvg.displayName = "QRCodeSvg";
1602
+ function bytesToBinaryString(bytes) {
1603
+ return bytes.map((b) => String.fromCharCode(b & 255)).join("");
1604
+ }
1605
+ function encodeStringToUtf8Bytes(input) {
1606
+ return Array.from(new TextEncoder().encode(input));
1607
+ }
1608
+ var QRCode = react.forwardRef(function QRCode2({ bgColor = "#FFFFFF", fgColor = "#000000", level = "L", size = 256, value, ...props }, ref) {
1609
+ const qrcode = new import_QRCode.default(-1, import_ErrorCorrectLevel.default[level]);
1610
+ const utf8Bytes = encodeStringToUtf8Bytes(value);
1611
+ const binaryString = bytesToBinaryString(utf8Bytes);
1612
+ qrcode.addData(binaryString, "Byte");
1613
+ qrcode.make();
1614
+ const cells = qrcode.modules;
1615
+ return /* @__PURE__ */ jsxRuntime.jsx(
1616
+ QRCodeSvg,
595
1617
  {
596
- className: "pollar-ramp-route-card",
597
- "data-recommended": quote.recommended,
598
- role: "button",
599
- tabIndex: 0,
600
- onClick: () => onSelect(quote),
601
- onKeyDown: (e) => e.key === "Enter" && onSelect(quote),
602
- children: [
603
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-route-left", children: [
604
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-route-provider", children: quote.provider }),
605
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-ramp-route-meta", children: [
606
- RAIL_LABELS[quote.rail] ?? quote.rail,
607
- " \xB7 ",
608
- quote.protocol,
609
- " \xB7 ",
610
- quote.estimatedTime
611
- ] })
612
- ] }),
613
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-route-right", children: [
614
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-ramp-route-fee", children: [
615
- quote.fee,
616
- "% fee"
617
- ] }),
618
- quote.recommended && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-route-badge", children: "Best rate" })
619
- ] })
620
- ]
1618
+ ...props,
1619
+ bgColor,
1620
+ bgD: cells.map((row, rowIndex) => row.map((cell, cellIndex) => !cell ? `M ${cellIndex} ${rowIndex} l 1 0 0 1 -1 0 Z` : "").join(" ")).join(" "),
1621
+ fgColor,
1622
+ fgD: cells.map((row, rowIndex) => row.map((cell, cellIndex) => cell ? `M ${cellIndex} ${rowIndex} l 1 0 0 1 -1 0 Z` : "").join(" ")).join(" "),
1623
+ ref,
1624
+ size,
1625
+ viewBoxSize: cells.length
621
1626
  }
622
1627
  );
623
- }
624
- var LOADING_STEPS = ["Detecting your country\u2026", "Consulting providers\u2026", "Route found!"];
625
- var COUNTRY_CURRENCIES = {
626
- MX: "MXN",
627
- BR: "BRL",
628
- CO: "COP",
629
- CL: "CLP",
630
- PE: "PEN",
631
- AR: "ARS"
632
- };
633
- function RampWidgetTemplate({
1628
+ });
1629
+ function ReceiveModalTemplate({
634
1630
  theme,
635
1631
  accentColor,
636
- step,
637
- direction,
638
- amount,
639
- currency,
640
- country,
641
- quotes,
642
- paymentInstructions,
643
- isLoading,
644
- onDirectionChange,
645
- onAmountChange,
646
- onCurrencyChange,
647
- onCountryChange,
648
- onFindRoute,
649
- onSelectQuote,
1632
+ walletAddress,
1633
+ copied,
650
1634
  onCopy,
651
1635
  onClose
652
1636
  }) {
@@ -666,13 +1650,183 @@ function RampWidgetTemplate({
666
1650
  "--pollar-buttons-height": "44px",
667
1651
  "--pollar-input-height": "44px",
668
1652
  "--pollar-input-border-radius": "0.5rem",
669
- "--pollar-card-border-radius": "10px",
670
- "--pollar-modal-padding": "2rem",
671
- "--pollar-modal-heading-size": "1.375rem",
672
- "--pollar-modal-subtitle-size": "0.9rem"
1653
+ "--pollar-card-border-radius": "10px"
673
1654
  };
674
- const stepTitle = {
675
- input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
1655
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1656
+ "div",
1657
+ {
1658
+ className: "pollar-modal-card pollar-receive-modal",
1659
+ "data-theme": theme,
1660
+ style: cssVars,
1661
+ onClick: (e) => e.stopPropagation(),
1662
+ children: [
1663
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
1664
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Receive" }),
1665
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }) })
1666
+ ] }),
1667
+ walletAddress ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1668
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-receive-qr", children: /* @__PURE__ */ jsxRuntime.jsx(
1669
+ QRCode,
1670
+ {
1671
+ value: walletAddress,
1672
+ size: 180,
1673
+ fgColor: isDark ? "#ffffff" : "#111827",
1674
+ bgColor: "transparent"
1675
+ }
1676
+ ) }),
1677
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-receive-instructions", children: "Share your Stellar address to receive any asset. Only send Stellar assets to this address." }),
1678
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-receive-address-row", children: [
1679
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-receive-address", children: walletAddress }),
1680
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-receive-copy-btn", onClick: onCopy, "aria-label": "Copy address", children: copied ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1681
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
1682
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
1683
+ /* @__PURE__ */ jsxRuntime.jsx(
1684
+ "path",
1685
+ {
1686
+ d: "M3.5 7l2.5 2.5 4.5-5",
1687
+ stroke: "white",
1688
+ strokeWidth: "1.5",
1689
+ strokeLinecap: "round",
1690
+ strokeLinejoin: "round"
1691
+ }
1692
+ )
1693
+ ] }),
1694
+ "Copied!"
1695
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1696
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
1697
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
1698
+ /* @__PURE__ */ jsxRuntime.jsx(
1699
+ "path",
1700
+ {
1701
+ d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
1702
+ stroke: "currentColor",
1703
+ strokeWidth: "1.5",
1704
+ strokeLinecap: "round"
1705
+ }
1706
+ )
1707
+ ] }),
1708
+ "Copy address"
1709
+ ] }) })
1710
+ ] })
1711
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No wallet connected." }),
1712
+ /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
1713
+ ]
1714
+ }
1715
+ );
1716
+ }
1717
+ function ReceiveModal({ onClose }) {
1718
+ const { walletAddress, styles } = usePollar();
1719
+ const { theme = "light", accentColor = "#005DB4" } = styles;
1720
+ const [copied, setCopied] = react.useState(false);
1721
+ function handleCopy() {
1722
+ if (!walletAddress) return;
1723
+ navigator.clipboard.writeText(walletAddress).then(() => {
1724
+ setCopied(true);
1725
+ setTimeout(() => setCopied(false), 2e3);
1726
+ });
1727
+ }
1728
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
1729
+ ReceiveModalTemplate,
1730
+ {
1731
+ theme,
1732
+ accentColor,
1733
+ walletAddress,
1734
+ copied,
1735
+ onCopy: handleCopy,
1736
+ onClose
1737
+ }
1738
+ ) });
1739
+ }
1740
+ var RAIL_LABELS = {
1741
+ SPEI: "SPEI (Mexico)",
1742
+ PIX: "PIX (Brazil)",
1743
+ PSE: "PSE (Colombia)",
1744
+ ACH: "ACH (US)"
1745
+ };
1746
+ function RouteDisplay({ quote, onSelect }) {
1747
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1748
+ "div",
1749
+ {
1750
+ className: "pollar-ramp-route-card",
1751
+ "data-recommended": quote.recommended,
1752
+ role: "button",
1753
+ tabIndex: 0,
1754
+ onClick: () => onSelect(quote),
1755
+ onKeyDown: (e) => e.key === "Enter" && onSelect(quote),
1756
+ children: [
1757
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-route-left", children: [
1758
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-route-provider", children: quote.provider }),
1759
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-ramp-route-meta", children: [
1760
+ RAIL_LABELS[quote.rail] ?? quote.rail,
1761
+ " \xB7 ",
1762
+ quote.protocol,
1763
+ " \xB7 ",
1764
+ quote.estimatedTime
1765
+ ] })
1766
+ ] }),
1767
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-route-right", children: [
1768
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-ramp-route-fee", children: [
1769
+ quote.fee,
1770
+ "% fee"
1771
+ ] }),
1772
+ quote.recommended && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-route-badge", children: "Best rate" })
1773
+ ] })
1774
+ ]
1775
+ }
1776
+ );
1777
+ }
1778
+ var LOADING_STEPS = ["Detecting your country\u2026", "Consulting providers\u2026", "Route found!"];
1779
+ var COUNTRY_CURRENCIES = {
1780
+ MX: "MXN",
1781
+ BR: "BRL",
1782
+ CO: "COP",
1783
+ CL: "CLP",
1784
+ PE: "PEN",
1785
+ AR: "ARS"
1786
+ };
1787
+ function RampWidgetTemplate({
1788
+ theme,
1789
+ accentColor,
1790
+ step,
1791
+ direction,
1792
+ amount,
1793
+ currency,
1794
+ country,
1795
+ quotes,
1796
+ paymentInstructions,
1797
+ isLoading,
1798
+ onDirectionChange,
1799
+ onAmountChange,
1800
+ onCurrencyChange,
1801
+ onCountryChange,
1802
+ onFindRoute,
1803
+ onSelectQuote,
1804
+ onCopy,
1805
+ onClose
1806
+ }) {
1807
+ const isDark = theme === "dark";
1808
+ const cssVars = {
1809
+ "--pollar-accent": accentColor,
1810
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
1811
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
1812
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
1813
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
1814
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
1815
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
1816
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
1817
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
1818
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
1819
+ "--pollar-buttons-border-radius": "6px",
1820
+ "--pollar-buttons-height": "44px",
1821
+ "--pollar-input-height": "44px",
1822
+ "--pollar-input-border-radius": "0.5rem",
1823
+ "--pollar-card-border-radius": "10px",
1824
+ "--pollar-modal-padding": "2rem",
1825
+ "--pollar-modal-heading-size": "1.375rem",
1826
+ "--pollar-modal-subtitle-size": "0.9rem"
1827
+ };
1828
+ const stepTitle = {
1829
+ input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
676
1830
  loading_quote: "Finding best route",
677
1831
  select_route: "Select provider",
678
1832
  payment_instructions: "Payment instructions"
@@ -905,38 +2059,18 @@ var STATUS_MESSAGES = {
905
2059
  success: "Transaction sent successfully",
906
2060
  error: "Transaction failed"
907
2061
  };
908
- function TransactionModalTemplate({
909
- theme,
910
- accentColor,
2062
+ function TxStatusView({
911
2063
  transaction,
912
2064
  showXdr,
913
2065
  copied,
914
2066
  explorerUrl,
915
2067
  walletType,
916
- onClose,
917
2068
  onSignAndSend,
918
2069
  onToggleXdr,
919
2070
  onCopyHash,
920
- onRetry
2071
+ onRetry,
2072
+ onDone
921
2073
  }) {
922
- const isDark = theme === "dark";
923
- const cssVars = {
924
- "--pollar-accent": accentColor,
925
- "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
926
- "--pollar-border": isDark ? "#374151" : "#e5e7eb",
927
- "--pollar-text": isDark ? "#ffffff" : "#111827",
928
- "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
929
- "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
930
- "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
931
- "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
932
- "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
933
- "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
934
- "--pollar-buttons-border-radius": "6px",
935
- "--pollar-buttons-height": "44px",
936
- "--pollar-input-height": "44px",
937
- "--pollar-input-border-radius": "0.5rem",
938
- "--pollar-card-border-radius": "10px"
939
- };
940
2074
  const buildData = "buildData" in transaction ? transaction.buildData : null;
941
2075
  const hash = transaction.step === "success" ? transaction.hash : null;
942
2076
  const errorDetails = transaction.step === "error" ? transaction.details ?? null : null;
@@ -945,23 +2079,9 @@ function TransactionModalTemplate({
945
2079
  const isSuccess = transaction.step === "success";
946
2080
  const isError = transaction.step === "error";
947
2081
  const showDetails = buildData !== null && (isBuilt || isSigning || isSuccess);
948
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-tx-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
949
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Transaction" }) }),
950
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(
951
- "svg",
952
- {
953
- width: "18",
954
- height: "18",
955
- viewBox: "0 0 24 24",
956
- fill: "none",
957
- stroke: "currentColor",
958
- strokeWidth: "2.5",
959
- strokeLinecap: "round",
960
- strokeLinejoin: "round",
961
- "aria-hidden": true,
962
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" })
963
- }
964
- ) }),
2082
+ const walletImg = walletType === core.WalletType.FREIGHTER ? LOGO_FREIGHTER : walletType === core.WalletType.ALBEDO ? LOGO_ALBEDO : LOGO_POLLAR;
2083
+ const walletAlt = walletType === core.WalletType.FREIGHTER ? "Freighter" : walletType === core.WalletType.ALBEDO ? "Albedo" : "Pollar";
2084
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
965
2085
  showDetails && buildData && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
966
2086
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-summary", children: [
967
2087
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-tx-summary-title", children: "Details" }),
@@ -1006,116 +2126,707 @@ function TransactionModalTemplate({
1006
2126
  /* @__PURE__ */ jsxRuntime.jsxs(
1007
2127
  "svg",
1008
2128
  {
1009
- viewBox: "0 0 88 88",
1010
- width: "88",
1011
- height: "88",
1012
- className: `pollar-tx-spinner-svg${isSigning ? " pollar-tx-spinner-rotating" : ""}`,
2129
+ viewBox: "0 0 88 88",
2130
+ width: "88",
2131
+ height: "88",
2132
+ className: `pollar-tx-spinner-svg${isSigning ? " pollar-tx-spinner-rotating" : ""}`,
2133
+ "aria-hidden": true,
2134
+ children: [
2135
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "44", cy: "44", r: "36", fill: "none", stroke: "var(--pollar-border)", strokeWidth: "3" }),
2136
+ /* @__PURE__ */ jsxRuntime.jsx(
2137
+ "circle",
2138
+ {
2139
+ cx: "44",
2140
+ cy: "44",
2141
+ r: "36",
2142
+ fill: "none",
2143
+ stroke: isSuccess ? "var(--pollar-success-text)" : isError ? "var(--pollar-error-text)" : "var(--pollar-accent)",
2144
+ strokeWidth: "3",
2145
+ strokeLinecap: "round",
2146
+ strokeDasharray: isSigning ? "169.6 56.6" : "999 0",
2147
+ transform: "rotate(-90 44 44)",
2148
+ style: { transition: isSigning ? "none" : "stroke 400ms, stroke-dasharray 400ms" }
2149
+ }
2150
+ )
2151
+ ]
2152
+ }
2153
+ ),
2154
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: walletImg, alt: walletAlt, className: "pollar-tx-wallet-img" }) })
2155
+ ] }),
2156
+ isSigning && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-tx-spinner-label", children: walletType === core.WalletType.FREIGHTER ? "Waiting for Freighter\u2026" : walletType === core.WalletType.ALBEDO ? "Waiting for Albedo\u2026" : "Signing and sending\u2026" }),
2157
+ isError && onRetry && "buildData" in transaction && transaction.buildData && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-secondary pollar-tx-retry-btn", onClick: onRetry, children: "Try again" })
2158
+ ] }),
2159
+ isSuccess && hash && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-result", children: [
2160
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-tx-result-label", children: "Transaction hash" }),
2161
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-tx-result-hash", children: hash }),
2162
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-result-actions", children: [
2163
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-tx-result-btn", onClick: onCopyHash, children: copied ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2164
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
2165
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
2166
+ /* @__PURE__ */ jsxRuntime.jsx(
2167
+ "path",
2168
+ {
2169
+ d: "M3.5 7l2.5 2.5 4.5-5",
2170
+ stroke: "white",
2171
+ strokeWidth: "1.5",
2172
+ strokeLinecap: "round",
2173
+ strokeLinejoin: "round"
2174
+ }
2175
+ )
2176
+ ] }),
2177
+ "Copied!"
2178
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2179
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
2180
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
2181
+ /* @__PURE__ */ jsxRuntime.jsx(
2182
+ "path",
2183
+ {
2184
+ d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
2185
+ stroke: "currentColor",
2186
+ strokeWidth: "1.5",
2187
+ strokeLinecap: "round"
2188
+ }
2189
+ )
2190
+ ] }),
2191
+ "Copy hash"
2192
+ ] }) }),
2193
+ explorerUrl && /* @__PURE__ */ jsxRuntime.jsxs("a", { className: "pollar-tx-result-btn", href: explorerUrl, target: "_blank", rel: "noopener noreferrer", children: [
2194
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
2195
+ /* @__PURE__ */ jsxRuntime.jsx(
2196
+ "path",
2197
+ {
2198
+ d: "M5 2H2a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V8",
2199
+ stroke: "currentColor",
2200
+ strokeWidth: "1.5",
2201
+ strokeLinecap: "round"
2202
+ }
2203
+ ),
2204
+ /* @__PURE__ */ jsxRuntime.jsx(
2205
+ "path",
2206
+ {
2207
+ d: "M8 1h4m0 0v4m0-4L6 7",
2208
+ stroke: "currentColor",
2209
+ strokeWidth: "1.5",
2210
+ strokeLinecap: "round",
2211
+ strokeLinejoin: "round"
2212
+ }
2213
+ )
2214
+ ] }),
2215
+ "View on Explorer"
2216
+ ] })
2217
+ ] })
2218
+ ] }),
2219
+ isSuccess && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onDone, children: "Done" }),
2220
+ /* @__PURE__ */ jsxRuntime.jsx(
2221
+ ModalStatusBanner,
2222
+ {
2223
+ message: STATUS_MESSAGES[transaction.step],
2224
+ status: isError ? "ERROR" : isSigning || transaction.step === "building" ? "LOADING" : isSuccess ? "SUCCESS" : "NONE"
2225
+ }
2226
+ )
2227
+ ] });
2228
+ }
2229
+ function formatBalance(balance) {
2230
+ const n = parseFloat(balance);
2231
+ return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
2232
+ }
2233
+ function assetKey(record) {
2234
+ return `${record.code}:${record.issuer ?? "native"}`;
2235
+ }
2236
+ function SendModalTemplate({
2237
+ theme,
2238
+ accentColor,
2239
+ step,
2240
+ txTitle,
2241
+ assets,
2242
+ selectedAsset,
2243
+ amount,
2244
+ destination,
2245
+ formError,
2246
+ isLoadingBalance,
2247
+ transaction,
2248
+ showXdr,
2249
+ copied,
2250
+ explorerUrl,
2251
+ walletType,
2252
+ showBack,
2253
+ isInProgress,
2254
+ onClose,
2255
+ onBack,
2256
+ onSelectAsset,
2257
+ onAmountChange,
2258
+ onDestinationChange,
2259
+ onSubmit,
2260
+ onSignAndSend,
2261
+ onToggleXdr,
2262
+ onCopyHash,
2263
+ onRetry,
2264
+ onDone
2265
+ }) {
2266
+ const isDark = theme === "dark";
2267
+ const cssVars = {
2268
+ "--pollar-accent": accentColor,
2269
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
2270
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
2271
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
2272
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
2273
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2274
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2275
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
2276
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
2277
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2278
+ "--pollar-buttons-border-radius": "6px",
2279
+ "--pollar-buttons-height": "44px",
2280
+ "--pollar-input-height": "44px",
2281
+ "--pollar-input-border-radius": "0.5rem",
2282
+ "--pollar-card-border-radius": "10px"
2283
+ };
2284
+ const enabledAssets = assets.filter((a) => a.enabledInApp);
2285
+ const otherAssets = assets.filter((a) => !a.enabledInApp);
2286
+ const selectedKey = selectedAsset ? assetKey(selectedAsset) : "";
2287
+ const canSubmit = !!selectedAsset && !!amount && !!destination.trim() && !isLoadingBalance;
2288
+ const title = step === "form" ? "Send" : txTitle;
2289
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2290
+ "div",
2291
+ {
2292
+ className: "pollar-modal-card pollar-send-modal",
2293
+ "data-theme": theme,
2294
+ style: cssVars,
2295
+ onClick: (e) => e.stopPropagation(),
2296
+ children: [
2297
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
2298
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-header-left", children: [
2299
+ showBack && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onBack, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
2300
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: title })
2301
+ ] }),
2302
+ !isInProgress && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }) })
2303
+ ] }),
2304
+ step === "form" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2305
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
2306
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Asset" }),
2307
+ isLoadingBalance ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxRuntime.jsxs(
2308
+ "select",
2309
+ {
2310
+ className: "pollar-input pollar-send-select",
2311
+ value: selectedKey,
2312
+ onChange: (e) => {
2313
+ const all = [...enabledAssets, ...otherAssets];
2314
+ const found = all.find((a) => assetKey(a) === e.target.value);
2315
+ if (found) onSelectAsset(found);
2316
+ },
2317
+ children: [
2318
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", disabled: true, children: "Select asset" }),
2319
+ enabledAssets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("optgroup", { label: "App assets", children: enabledAssets.map((a) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: assetKey(a), children: [
2320
+ a.code,
2321
+ " \u2014 ",
2322
+ formatBalance(a.available),
2323
+ " available"
2324
+ ] }, assetKey(a))) }),
2325
+ otherAssets.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("optgroup", { label: "Other assets", children: otherAssets.map((a) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: assetKey(a), children: [
2326
+ a.code,
2327
+ " \u2014 ",
2328
+ formatBalance(a.available),
2329
+ " available"
2330
+ ] }, assetKey(a))) })
2331
+ ]
2332
+ }
2333
+ )
2334
+ ] }),
2335
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
2336
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-label-row", children: [
2337
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Amount" }),
2338
+ selectedAsset && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-send-hint", children: [
2339
+ "Available: ",
2340
+ formatBalance(selectedAsset.available),
2341
+ " ",
2342
+ selectedAsset.code
2343
+ ] })
2344
+ ] }),
2345
+ /* @__PURE__ */ jsxRuntime.jsx(
2346
+ "input",
2347
+ {
2348
+ className: "pollar-input",
2349
+ type: "text",
2350
+ inputMode: "decimal",
2351
+ placeholder: "0.00",
2352
+ value: amount,
2353
+ onChange: (e) => onAmountChange(e.target.value)
2354
+ }
2355
+ )
2356
+ ] }),
2357
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-send-field", children: [
2358
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "pollar-send-label", children: "Destination wallet" }),
2359
+ /* @__PURE__ */ jsxRuntime.jsx(
2360
+ "input",
2361
+ {
2362
+ className: "pollar-input",
2363
+ type: "text",
2364
+ placeholder: "G\u2026",
2365
+ value: destination,
2366
+ onChange: (e) => onDestinationChange(e.target.value)
2367
+ }
2368
+ )
2369
+ ] }),
2370
+ formError && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-error", children: formError }),
2371
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary", onClick: onSubmit, disabled: !canSubmit, children: "Continue" }) })
2372
+ ] }),
2373
+ step === "tx" && /* @__PURE__ */ jsxRuntime.jsx(
2374
+ TxStatusView,
2375
+ {
2376
+ transaction,
2377
+ showXdr,
2378
+ copied,
2379
+ explorerUrl,
2380
+ walletType,
2381
+ onSignAndSend,
2382
+ onToggleXdr,
2383
+ onCopyHash,
2384
+ onRetry,
2385
+ onDone
2386
+ }
2387
+ ),
2388
+ /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
2389
+ ]
2390
+ }
2391
+ );
2392
+ }
2393
+ function assetParam(record) {
2394
+ if (record.type === "native") return { type: "native" };
2395
+ if (record.type === "credit_alphanum4") {
2396
+ return { type: "credit_alphanum4", code: record.code, issuer: record.issuer };
2397
+ }
2398
+ return { type: "credit_alphanum12", code: record.code, issuer: record.issuer };
2399
+ }
2400
+ function SendModal({ onClose }) {
2401
+ const { walletBalance, refreshWalletBalance, buildTx, signAndSubmitTx, tx: transaction, walletType, network, styles } = usePollar();
2402
+ const { theme = "light", accentColor = "#005DB4" } = styles;
2403
+ const [step, setStep] = react.useState("form");
2404
+ const [amount, setAmount] = react.useState("");
2405
+ const [destination, setDestination] = react.useState("");
2406
+ const [selectedAsset, setSelectedAsset] = react.useState(null);
2407
+ const [showXdr, setShowXdr] = react.useState(false);
2408
+ const [copied, setCopied] = react.useState(false);
2409
+ const [formError, setFormError] = react.useState("");
2410
+ react.useEffect(() => {
2411
+ void refreshWalletBalance();
2412
+ }, [refreshWalletBalance]);
2413
+ const balanceData = walletBalance.step === "loaded" ? walletBalance.data : null;
2414
+ const allAssets = balanceData?.balances ?? [];
2415
+ const sortedAssets = [
2416
+ ...allAssets.filter((b) => b.enabledInApp),
2417
+ ...allAssets.filter((b) => !b.enabledInApp && parseFloat(b.balance) > 0)
2418
+ ];
2419
+ const hash = transaction.step === "success" ? transaction.hash : null;
2420
+ const buildData = "buildData" in transaction ? transaction.buildData : null;
2421
+ const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
2422
+ const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
2423
+ const isInProgress = transaction.step === "building" || transaction.step === "signing";
2424
+ const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
2425
+ const txTitle = transaction.step === "signing" ? "Sending\u2026" : transaction.step === "success" ? "Sent!" : transaction.step === "error" ? "Send failed" : "Confirm Send";
2426
+ async function handleSubmit() {
2427
+ setFormError("");
2428
+ if (!selectedAsset) {
2429
+ setFormError("Select an asset");
2430
+ return;
2431
+ }
2432
+ const parsed = parseFloat(amount);
2433
+ if (!amount || isNaN(parsed) || parsed <= 0) {
2434
+ setFormError("Enter a valid amount");
2435
+ return;
2436
+ }
2437
+ if (parsed > parseFloat(selectedAsset.available)) {
2438
+ setFormError("Insufficient balance");
2439
+ return;
2440
+ }
2441
+ if (!destination.trim()) {
2442
+ setFormError("Enter a destination address");
2443
+ return;
2444
+ }
2445
+ setStep("tx");
2446
+ await buildTx("payment", { destination: destination.trim(), amount, asset: assetParam(selectedAsset) });
2447
+ }
2448
+ function handleSignAndSend() {
2449
+ if (transaction.step === "built") {
2450
+ void signAndSubmitTx(transaction.buildData.unsignedXdr);
2451
+ }
2452
+ }
2453
+ function handleCopyHash() {
2454
+ if (!hash) return;
2455
+ navigator.clipboard.writeText(hash).then(() => {
2456
+ setCopied(true);
2457
+ setTimeout(() => setCopied(false), 2e3);
2458
+ });
2459
+ }
2460
+ async function handleRetry() {
2461
+ if (transaction.step === "error" && transaction.buildData) {
2462
+ await signAndSubmitTx(transaction.buildData.unsignedXdr);
2463
+ }
2464
+ }
2465
+ function handleBack() {
2466
+ setStep("form");
2467
+ setShowXdr(false);
2468
+ setCopied(false);
2469
+ }
2470
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
2471
+ SendModalTemplate,
2472
+ {
2473
+ theme,
2474
+ accentColor,
2475
+ step,
2476
+ txTitle,
2477
+ assets: sortedAssets,
2478
+ selectedAsset,
2479
+ amount,
2480
+ destination,
2481
+ formError,
2482
+ isLoadingBalance: walletBalance.step === "loading",
2483
+ transaction,
2484
+ showXdr,
2485
+ copied,
2486
+ explorerUrl,
2487
+ walletType,
2488
+ showBack,
2489
+ isInProgress,
2490
+ onClose,
2491
+ onBack: handleBack,
2492
+ onSelectAsset: setSelectedAsset,
2493
+ onAmountChange: setAmount,
2494
+ onDestinationChange: setDestination,
2495
+ onSubmit: () => void handleSubmit(),
2496
+ onSignAndSend: handleSignAndSend,
2497
+ onToggleXdr: () => setShowXdr((v) => !v),
2498
+ onCopyHash: handleCopyHash,
2499
+ onRetry: () => void handleRetry(),
2500
+ onDone: onClose
2501
+ }
2502
+ ) });
2503
+ }
2504
+ function describeDevice(s) {
2505
+ if (s.deviceLabel) return s.deviceLabel;
2506
+ if (!s.userAgent) return "Unknown device";
2507
+ return parseUserAgent(s.userAgent);
2508
+ }
2509
+ function detectBrowser(ua) {
2510
+ if (/Edg\//.test(ua)) return "Edge";
2511
+ if (/OPR\//.test(ua)) return "Opera";
2512
+ if (/(Chrome|CriOS)\//.test(ua)) return "Chrome";
2513
+ if (/(Firefox|FxiOS)\//.test(ua)) return "Firefox";
2514
+ if (/Safari\//.test(ua)) return "Safari";
2515
+ return null;
2516
+ }
2517
+ function detectOS(ua) {
2518
+ if (/iPhone|iPad|iPod/.test(ua)) return "iOS";
2519
+ if (/Android/.test(ua)) return "Android";
2520
+ if (/Mac OS X/.test(ua)) return "macOS";
2521
+ if (/Windows NT/.test(ua)) return "Windows";
2522
+ if (/Linux/.test(ua)) return "Linux";
2523
+ return null;
2524
+ }
2525
+ function parseUserAgent(ua) {
2526
+ const browser = detectBrowser(ua);
2527
+ const os = detectOS(ua);
2528
+ if (browser && os) return `${os} \u2014 ${browser}`;
2529
+ if (os) return os;
2530
+ if (browser) return browser;
2531
+ return ua.slice(0, 48);
2532
+ }
2533
+ function formatRelative(iso) {
2534
+ if (!iso) return "\u2014";
2535
+ const ts = new Date(iso).getTime();
2536
+ if (!Number.isFinite(ts)) return "\u2014";
2537
+ const diffSec = Math.round((Date.now() - ts) / 1e3);
2538
+ if (diffSec < 0) return "just now";
2539
+ if (diffSec < 60) return `${diffSec}s ago`;
2540
+ const diffMin = Math.round(diffSec / 60);
2541
+ if (diffMin < 60) return `${diffMin}m ago`;
2542
+ const diffHr = Math.round(diffMin / 60);
2543
+ if (diffHr < 24) return `${diffHr}h ago`;
2544
+ const diffDay = Math.round(diffHr / 24);
2545
+ if (diffDay < 30) return `${diffDay}d ago`;
2546
+ return new Date(iso).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
2547
+ }
2548
+ function shortIp(hash) {
2549
+ if (!hash) return "";
2550
+ return hash.slice(0, 8);
2551
+ }
2552
+ function SessionsModalTemplate({
2553
+ theme,
2554
+ accentColor,
2555
+ state,
2556
+ revokingFamilyId,
2557
+ signingOutEverywhere,
2558
+ onRefresh,
2559
+ onRevoke,
2560
+ onLogoutEverywhere,
2561
+ onClose
2562
+ }) {
2563
+ const isDark = theme === "dark";
2564
+ const cssVars = {
2565
+ "--pollar-accent": accentColor,
2566
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
2567
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
2568
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
2569
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
2570
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2571
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2572
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
2573
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
2574
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2575
+ "--pollar-buttons-border-radius": "6px",
2576
+ "--pollar-buttons-height": "44px",
2577
+ "--pollar-input-height": "44px",
2578
+ "--pollar-input-border-radius": "0.5rem",
2579
+ "--pollar-card-border-radius": "10px"
2580
+ };
2581
+ const isLoading = state.step === "loading";
2582
+ const sessions = state.step === "loaded" ? state.sessions : [];
2583
+ const otherCount = sessions.filter((s) => !s.current).length;
2584
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2585
+ "div",
2586
+ {
2587
+ className: "pollar-modal-card pollar-sessions-modal",
2588
+ "data-theme": theme,
2589
+ style: cssVars,
2590
+ onClick: (e) => e.stopPropagation(),
2591
+ children: [
2592
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
2593
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Active sessions" }),
2594
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
2595
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "pollar-modal-refresh-btn", onClick: onRefresh, disabled: isLoading, children: [
2596
+ /* @__PURE__ */ jsxRuntime.jsxs(
2597
+ "svg",
2598
+ {
2599
+ className: `pollar-modal-refresh-icon${isLoading ? " spinning" : ""}`,
2600
+ width: "13",
2601
+ height: "13",
2602
+ viewBox: "0 0 13 13",
2603
+ fill: "none",
2604
+ "aria-hidden": true,
2605
+ children: [
2606
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M11.5 6.5a5 5 0 11-1.5-3.536", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
2607
+ /* @__PURE__ */ jsxRuntime.jsx(
2608
+ "path",
2609
+ {
2610
+ d: "M10 1v3h-3",
2611
+ stroke: "currentColor",
2612
+ strokeWidth: "1.5",
2613
+ strokeLinecap: "round",
2614
+ strokeLinejoin: "round"
2615
+ }
2616
+ )
2617
+ ]
2618
+ }
2619
+ ),
2620
+ "Refresh"
2621
+ ] }),
2622
+ /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
2623
+ ] })
2624
+ ] }),
2625
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-list", children: [
2626
+ state.step === "idle" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
2627
+ isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
2628
+ state.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: state.message }),
2629
+ state.step === "loaded" && sessions.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No active sessions." }),
2630
+ sessions.map((s) => {
2631
+ const isRevoking = revokingFamilyId === s.familyId;
2632
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-item", "data-current": s.current || void 0, children: [
2633
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-item-main", children: [
2634
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-item-device", children: describeDevice(s) }),
2635
+ s.current && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-sessions-item-badge", children: "This device" })
2636
+ ] }),
2637
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-sessions-item-meta", children: [
2638
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2639
+ "Last used ",
2640
+ formatRelative(s.lastUsedAt ?? s.createdAt)
2641
+ ] }),
2642
+ s.ipHash && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2643
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xB7" }),
2644
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { title: `ip-hash ${s.ipHash}`, children: [
2645
+ "ip ",
2646
+ shortIp(s.ipHash)
2647
+ ] })
2648
+ ] })
2649
+ ] }),
2650
+ !s.current && /* @__PURE__ */ jsxRuntime.jsx(
2651
+ "button",
2652
+ {
2653
+ className: "pollar-sessions-item-revoke",
2654
+ onClick: () => onRevoke(s.familyId),
2655
+ disabled: isRevoking || signingOutEverywhere,
2656
+ children: isRevoking ? "Revoking\u2026" : "Revoke"
2657
+ }
2658
+ )
2659
+ ] }, s.familyId);
2660
+ })
2661
+ ] }),
2662
+ state.step === "loaded" && sessions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-sessions-actions", children: /* @__PURE__ */ jsxRuntime.jsx(
2663
+ "button",
2664
+ {
2665
+ className: "pollar-sessions-logout-all",
2666
+ onClick: onLogoutEverywhere,
2667
+ disabled: signingOutEverywhere || otherCount === 0,
2668
+ title: otherCount === 0 ? "No other devices to sign out" : void 0,
2669
+ children: signingOutEverywhere ? "Signing out\u2026" : "Sign out everywhere"
2670
+ }
2671
+ ) }),
2672
+ /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
2673
+ ]
2674
+ }
2675
+ );
2676
+ }
2677
+ function SessionsModal({ onClose }) {
2678
+ const { getClient, styles } = usePollar();
2679
+ const { theme = "light", accentColor = "#005DB4" } = styles;
2680
+ const [state, setState] = react.useState({ step: "idle" });
2681
+ const [revokingFamilyId, setRevokingFamilyId] = react.useState(null);
2682
+ const [signingOutEverywhere, setSigningOutEverywhere] = react.useState(false);
2683
+ const mountedRef = react.useRef(true);
2684
+ react.useEffect(() => () => {
2685
+ mountedRef.current = false;
2686
+ }, []);
2687
+ const onCloseRef = react.useRef(onClose);
2688
+ onCloseRef.current = onClose;
2689
+ react.useEffect(() => {
2690
+ return getClient().onAuthStateChange((authState) => {
2691
+ if (authState.step === "idle") onCloseRef.current();
2692
+ });
2693
+ }, [getClient]);
2694
+ const load = react.useCallback(async () => {
2695
+ setState({ step: "loading" });
2696
+ try {
2697
+ const sessions = await getClient().listSessions();
2698
+ if (!mountedRef.current) return;
2699
+ setState({ step: "loaded", sessions });
2700
+ } catch (err) {
2701
+ if (!mountedRef.current) return;
2702
+ const message = err instanceof Error ? err.message : "Failed to load sessions";
2703
+ setState({ step: "error", message });
2704
+ }
2705
+ }, [getClient]);
2706
+ react.useEffect(() => {
2707
+ void load();
2708
+ }, [load]);
2709
+ const handleRevoke = react.useCallback(
2710
+ async (familyId) => {
2711
+ setRevokingFamilyId(familyId);
2712
+ try {
2713
+ await getClient().revokeSession(familyId);
2714
+ if (!mountedRef.current) return;
2715
+ await load();
2716
+ } catch {
2717
+ if (!mountedRef.current) return;
2718
+ setState(
2719
+ (prev) => prev.step === "loaded" ? { step: "error", message: "Failed to revoke session" } : prev
2720
+ );
2721
+ } finally {
2722
+ if (mountedRef.current) setRevokingFamilyId(null);
2723
+ }
2724
+ },
2725
+ [getClient, load]
2726
+ );
2727
+ const handleLogoutEverywhere = react.useCallback(async () => {
2728
+ setSigningOutEverywhere(true);
2729
+ try {
2730
+ await getClient().logoutEverywhere();
2731
+ onClose();
2732
+ } catch {
2733
+ if (!mountedRef.current) return;
2734
+ setSigningOutEverywhere(false);
2735
+ }
2736
+ }, [getClient, onClose]);
2737
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
2738
+ SessionsModalTemplate,
2739
+ {
2740
+ theme,
2741
+ accentColor,
2742
+ state,
2743
+ revokingFamilyId,
2744
+ signingOutEverywhere,
2745
+ onRefresh: () => void load(),
2746
+ onRevoke: (familyId) => void handleRevoke(familyId),
2747
+ onLogoutEverywhere: () => void handleLogoutEverywhere(),
2748
+ onClose
2749
+ }
2750
+ ) });
2751
+ }
2752
+ function TransactionModalTemplate({
2753
+ theme,
2754
+ accentColor,
2755
+ transaction,
2756
+ showXdr,
2757
+ copied,
2758
+ explorerUrl,
2759
+ walletType,
2760
+ onClose,
2761
+ onSignAndSend,
2762
+ onToggleXdr,
2763
+ onCopyHash,
2764
+ onRetry
2765
+ }) {
2766
+ const isDark = theme === "dark";
2767
+ const cssVars = {
2768
+ "--pollar-accent": accentColor,
2769
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
2770
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
2771
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
2772
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
2773
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2774
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2775
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
2776
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
2777
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2778
+ "--pollar-buttons-border-radius": "6px",
2779
+ "--pollar-buttons-height": "44px",
2780
+ "--pollar-input-height": "44px",
2781
+ "--pollar-input-border-radius": "0.5rem",
2782
+ "--pollar-card-border-radius": "10px"
2783
+ };
2784
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2785
+ "div",
2786
+ {
2787
+ className: "pollar-modal-card pollar-tx-modal",
2788
+ "data-theme": theme,
2789
+ style: cssVars,
2790
+ onClick: (e) => e.stopPropagation(),
2791
+ children: [
2792
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Transaction" }) }),
2793
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(
2794
+ "svg",
2795
+ {
2796
+ width: "18",
2797
+ height: "18",
2798
+ viewBox: "0 0 24 24",
2799
+ fill: "none",
2800
+ stroke: "currentColor",
2801
+ strokeWidth: "2.5",
2802
+ strokeLinecap: "round",
2803
+ strokeLinejoin: "round",
1013
2804
  "aria-hidden": true,
1014
- children: [
1015
- /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "44", cy: "44", r: "36", fill: "none", stroke: "var(--pollar-border)", strokeWidth: "3" }),
1016
- /* @__PURE__ */ jsxRuntime.jsx(
1017
- "circle",
1018
- {
1019
- cx: "44",
1020
- cy: "44",
1021
- r: "36",
1022
- fill: "none",
1023
- stroke: isSuccess ? "var(--pollar-success-text)" : isError ? "var(--pollar-error-text)" : "var(--pollar-accent)",
1024
- strokeWidth: "3",
1025
- strokeLinecap: "round",
1026
- strokeDasharray: isSigning ? "169.6 56.6" : "999 0",
1027
- transform: "rotate(-90 44 44)",
1028
- style: { transition: isSigning ? "none" : "stroke 400ms, stroke-dasharray 400ms" }
1029
- }
1030
- )
1031
- ]
2805
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" })
1032
2806
  }
1033
- ),
1034
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsxRuntime.jsx(
1035
- "img",
2807
+ ) }),
2808
+ /* @__PURE__ */ jsxRuntime.jsx(
2809
+ TxStatusView,
1036
2810
  {
1037
- src: walletType === core.WalletType.FREIGHTER ? LOGO_FREIGHTER : walletType === core.WalletType.ALBEDO ? LOGO_ALBEDO : LOGO_POLLAR,
1038
- alt: walletType === core.WalletType.FREIGHTER ? "Freighter" : walletType === core.WalletType.ALBEDO ? "Albedo" : "Pollar",
1039
- className: "pollar-tx-wallet-img"
2811
+ transaction,
2812
+ showXdr,
2813
+ copied,
2814
+ explorerUrl,
2815
+ walletType,
2816
+ onSignAndSend,
2817
+ onToggleXdr,
2818
+ onCopyHash,
2819
+ onRetry,
2820
+ onDone: onClose
1040
2821
  }
1041
- ) })
1042
- ] }),
1043
- isSigning && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-tx-spinner-label", children: walletType === core.WalletType.FREIGHTER ? "Waiting for Freighter\u2026" : walletType === core.WalletType.ALBEDO ? "Waiting for Albedo\u2026" : "Signing and sending\u2026" }),
1044
- isError && onRetry && "buildData" in transaction && transaction.buildData && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-secondary pollar-tx-retry-btn", onClick: onRetry, children: "Try again" })
1045
- ] }),
1046
- isSuccess && hash && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-result", children: [
1047
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-tx-result-label", children: "Transaction hash" }),
1048
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-tx-result-hash", children: hash }),
1049
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-result-actions", children: [
1050
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-tx-result-btn", onClick: onCopyHash, children: copied ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1051
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
1052
- /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
1053
- /* @__PURE__ */ jsxRuntime.jsx(
1054
- "path",
1055
- {
1056
- d: "M3.5 7l2.5 2.5 4.5-5",
1057
- stroke: "white",
1058
- strokeWidth: "1.5",
1059
- strokeLinecap: "round",
1060
- strokeLinejoin: "round"
1061
- }
1062
- )
1063
- ] }),
1064
- "Copied!"
1065
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1066
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
1067
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
1068
- /* @__PURE__ */ jsxRuntime.jsx(
1069
- "path",
1070
- {
1071
- d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
1072
- stroke: "currentColor",
1073
- strokeWidth: "1.5",
1074
- strokeLinecap: "round"
1075
- }
1076
- )
1077
- ] }),
1078
- "Copy hash"
1079
- ] }) }),
1080
- explorerUrl && /* @__PURE__ */ jsxRuntime.jsxs("a", { className: "pollar-tx-result-btn", href: explorerUrl, target: "_blank", rel: "noopener noreferrer", children: [
1081
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
1082
- /* @__PURE__ */ jsxRuntime.jsx(
1083
- "path",
1084
- {
1085
- d: "M5 2H2a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V8",
1086
- stroke: "currentColor",
1087
- strokeWidth: "1.5",
1088
- strokeLinecap: "round"
1089
- }
1090
- ),
1091
- /* @__PURE__ */ jsxRuntime.jsx(
1092
- "path",
1093
- {
1094
- d: "M8 1h4m0 0v4m0-4L6 7",
1095
- stroke: "currentColor",
1096
- strokeWidth: "1.5",
1097
- strokeLinecap: "round",
1098
- strokeLinejoin: "round"
1099
- }
1100
- )
1101
- ] }),
1102
- "View on Explorer"
1103
- ] })
1104
- ] })
1105
- ] }),
1106
- isSuccess && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onClose, children: "Done" }),
1107
- /* @__PURE__ */ jsxRuntime.jsx(
1108
- ModalStatusBanner,
1109
- {
1110
- message: STATUS_MESSAGES[transaction.step],
1111
- status: isError ? "ERROR" : isSigning || transaction.step === "building" ? "LOADING" : isSuccess ? "SUCCESS" : "NONE"
1112
- }
1113
- ),
1114
- /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
1115
- ] });
2822
+ ),
2823
+ /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
2824
+ ]
2825
+ }
2826
+ );
1116
2827
  }
1117
2828
  function TransactionModal({ onClose }) {
1118
- const { getClient, styles, transaction, network, walletType } = usePollar();
2829
+ const { getClient, styles, tx: transaction, network, walletType } = usePollar();
1119
2830
  const { theme = "light", accentColor = "#005DB4" } = styles;
1120
2831
  const [showXdr, setShowXdr] = react.useState(false);
1121
2832
  const [copied, setCopied] = react.useState(false);
@@ -1286,10 +2997,13 @@ function TxHistoryModal({ onClose }) {
1286
2997
  const { getClient, styles, txHistory } = usePollar();
1287
2998
  const { theme = "light", accentColor = "#005DB4" } = styles;
1288
2999
  const [offset, setOffset] = react.useState(0);
1289
- function load(nextOffset) {
3000
+ const load = react.useCallback((nextOffset) => {
1290
3001
  setOffset(nextOffset);
1291
3002
  void getClient().fetchTxHistory({ limit: PAGE_SIZE2, offset: nextOffset });
1292
- }
3003
+ }, [getClient]);
3004
+ react.useEffect(() => {
3005
+ load(0);
3006
+ }, [load]);
1293
3007
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
1294
3008
  TxHistoryModalTemplate,
1295
3009
  {
@@ -1304,7 +3018,7 @@ function TxHistoryModal({ onClose }) {
1304
3018
  }
1305
3019
  ) });
1306
3020
  }
1307
- function formatBalance(balance) {
3021
+ function formatBalance2(balance) {
1308
3022
  const n = parseFloat(balance);
1309
3023
  return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
1310
3024
  }
@@ -1317,9 +3031,9 @@ function BalanceItem({ record }) {
1317
3031
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-item", children: [
1318
3032
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-asset", children: record.code }),
1319
3033
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-amounts", children: [
1320
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-amount", children: formatBalance(record.balance) }),
3034
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-amount", children: formatBalance2(record.balance) }),
1321
3035
  balanceDiffers && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-bal-available", children: [
1322
- formatBalance(record.available),
3036
+ formatBalance2(record.available),
1323
3037
  " available"
1324
3038
  ] })
1325
3039
  ] })
@@ -1392,11 +3106,11 @@ function WalletBalanceModalTemplate({
1392
3106
  ] });
1393
3107
  }
1394
3108
  function WalletBalanceModal({ onClose }) {
1395
- const { walletBalance, refreshBalance, walletAddress, styles } = usePollar();
3109
+ const { walletBalance, refreshWalletBalance, walletAddress, styles } = usePollar();
1396
3110
  const { theme = "light", accentColor = "#005DB4" } = styles;
1397
3111
  react.useEffect(() => {
1398
- void refreshBalance();
1399
- }, []);
3112
+ void refreshWalletBalance();
3113
+ }, [refreshWalletBalance]);
1400
3114
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
1401
3115
  WalletBalanceModalTemplate,
1402
3116
  {
@@ -1404,7 +3118,7 @@ function WalletBalanceModal({ onClose }) {
1404
3118
  accentColor,
1405
3119
  walletBalance,
1406
3120
  walletAddress,
1407
- onRefresh: () => refreshBalance(),
3121
+ onRefresh: () => refreshWalletBalance(),
1408
3122
  onClose
1409
3123
  }
1410
3124
  ) });
@@ -1429,6 +3143,8 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1429
3143
  const [walletBalance, setWalletBalance] = react.useState({ step: "idle" });
1430
3144
  const [remoteConfig, setRemoteConfig] = react.useState(emptyResponse);
1431
3145
  const [styles, setStyles] = react.useState(propStyles ?? {});
3146
+ const propStylesRef = react.useRef(propStyles);
3147
+ propStylesRef.current = propStyles;
1432
3148
  react.useEffect(() => {
1433
3149
  return pollarClient.onTransactionStateChange(setTransaction);
1434
3150
  }, [pollarClient]);
@@ -1453,59 +3169,78 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1453
3169
  });
1454
3170
  }, [pollarClient]);
1455
3171
  react.useEffect(() => {
3172
+ const propStyles2 = propStylesRef.current;
1456
3173
  fetchRemoteConfig(pollarClient).then((fetched) => {
1457
3174
  setRemoteConfig(fetched);
1458
3175
  setStyles({
1459
3176
  ...fetched.styles,
1460
- ...propStyles,
1461
- providers: { ...fetched.styles?.providers, ...propStyles?.providers }
3177
+ ...propStyles2,
3178
+ providers: { ...fetched.styles?.providers, ...propStyles2?.providers }
1462
3179
  });
1463
3180
  }).catch(() => {
1464
- setStyles(propStyles ?? {});
3181
+ setStyles(propStyles2 ?? {});
1465
3182
  });
1466
3183
  }, [pollarClient]);
1467
- react.useEffect(() => {
1468
- if (transaction.step !== "idle") {
1469
- setTransactionModalOpen(true);
1470
- }
1471
- }, [transaction.step]);
1472
3184
  const [loginModalOpen, setLoginModalOpen] = react.useState(false);
1473
3185
  const [transactionModalOpen, setTransactionModalOpen] = react.useState(false);
1474
3186
  const [kycModalOpen, setKycModalOpen] = react.useState(false);
1475
3187
  const [kycModalOptions, setKycModalOptions] = react.useState({});
1476
- const [rampWidgetOpen, setRampWidgetOpen] = react.useState(false);
3188
+ const [rampModalOpen, setRampModalOpen] = react.useState(false);
1477
3189
  const [txHistoryModalOpen, setTxHistoryModalOpen] = react.useState(false);
1478
3190
  const [walletBalanceModalOpen, setWalletBalanceModalOpen] = react.useState(false);
3191
+ const [sendModalOpen, setSendModalOpen] = react.useState(false);
3192
+ const [receiveModalOpen, setReceiveModalOpen] = react.useState(false);
3193
+ const [sessionsModalOpen, setSessionsModalOpen] = react.useState(false);
3194
+ const adaptersRef = react.useRef(adapters);
3195
+ adaptersRef.current = adapters;
3196
+ const walletAddress = sessionState?.wallet?.publicKey || "";
3197
+ const getClient = react.useCallback(() => pollarClient, [pollarClient]);
3198
+ const refreshWalletBalance = react.useCallback(() => pollarClient.refreshBalance(walletAddress), [pollarClient, walletAddress]);
1479
3199
  const contextValue = react.useMemo(
1480
3200
  () => ({
1481
- walletAddress: sessionState?.data?.providers?.wallet?.address || sessionState?.wallet?.publicKey || "",
1482
- getClient: () => pollarClient,
1483
- transaction,
3201
+ // session
3202
+ walletAddress,
3203
+ isAuthenticated: !!walletAddress,
3204
+ walletType: pollarClient.getWalletType(),
3205
+ // client
3206
+ getClient,
3207
+ // auth
1484
3208
  login: (options) => pollarClient.login(options),
1485
3209
  logout: () => pollarClient.logout(),
1486
- isAuthenticated: !!sessionState?.wallet?.publicKey,
3210
+ openLoginModal: () => setLoginModalOpen(true),
3211
+ // transactions
3212
+ tx: transaction,
1487
3213
  buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
1488
3214
  signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
1489
- walletType: pollarClient.getWalletType(),
1490
- openTransactionModal: () => setTransactionModalOpen(true),
1491
- openLoginModal: () => setLoginModalOpen(true),
1492
- openKycModal: (options = {}) => {
1493
- setKycModalOptions(options);
1494
- setKycModalOpen(true);
1495
- },
1496
- openRampWidget: () => setRampWidgetOpen(true),
3215
+ openTxModal: () => setTransactionModalOpen(true),
3216
+ // tx history
1497
3217
  txHistory,
1498
3218
  openTxHistoryModal: () => setTxHistoryModalOpen(true),
1499
- openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
3219
+ // wallet balance
1500
3220
  walletBalance,
1501
- refreshBalance: (publicKey) => pollarClient.refreshBalance(publicKey),
3221
+ refreshWalletBalance,
3222
+ openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
3223
+ // send / receive
3224
+ openSendModal: () => setSendModalOpen(true),
3225
+ openReceiveModal: () => setReceiveModalOpen(true),
3226
+ // sessions
3227
+ openSessionsModal: () => setSessionsModalOpen(true),
3228
+ // network
1502
3229
  network: networkState.step === "connected" ? networkState.network : "testnet",
1503
3230
  setNetwork: (network) => pollarClient.setNetwork(network),
1504
- config: remoteConfig,
3231
+ // kyc
3232
+ openKycModal: (options = {}) => {
3233
+ setKycModalOptions(options);
3234
+ setKycModalOpen(true);
3235
+ },
3236
+ // ramp
3237
+ openRampModal: () => setRampModalOpen(true),
3238
+ // config
3239
+ appConfig: remoteConfig,
1505
3240
  styles,
1506
- adapters
3241
+ adapters: adaptersRef.current
1507
3242
  }),
1508
- [sessionState, remoteConfig, styles, pollarClient, transaction, txHistory, networkState, walletBalance]
3243
+ [walletAddress, pollarClient, getClient, transaction, txHistory, walletBalance, refreshWalletBalance, networkState, remoteConfig, styles]
1509
3244
  );
1510
3245
  return /* @__PURE__ */ jsxRuntime.jsxs(PollarContext.Provider, { value: contextValue, children: [
1511
3246
  children,
@@ -1520,9 +3255,12 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1520
3255
  ...kycModalOptions.onApproved !== void 0 && { onApproved: kycModalOptions.onApproved }
1521
3256
  }
1522
3257
  ) }),
1523
- rampWidgetOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setRampWidgetOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(RampWidget, { onClose: () => setRampWidgetOpen(false) }) }),
3258
+ rampModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setRampModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(RampWidget, { onClose: () => setRampModalOpen(false) }) }),
1524
3259
  txHistoryModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setTxHistoryModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryModal, { onClose: () => setTxHistoryModalOpen(false) }) }),
1525
- walletBalanceModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) })
3260
+ walletBalanceModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) }),
3261
+ sendModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }),
3262
+ receiveModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false) }) }),
3263
+ sessionsModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSessionsModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SessionsModal, { onClose: () => setSessionsModalOpen(false) }) })
1526
3264
  ] });
1527
3265
  }
1528
3266
  function usePollar() {
@@ -1568,10 +3306,13 @@ function WalletButtonTemplate({
1568
3306
  dropdownBorder,
1569
3307
  itemColor,
1570
3308
  wrapperRef,
3309
+ isInProgress,
1571
3310
  onToggleOpen,
1572
3311
  onCopy,
1573
3312
  onWalletBalance,
1574
3313
  onTxHistory,
3314
+ onSend,
3315
+ onReceive,
1575
3316
  onLogout,
1576
3317
  onLogin
1577
3318
  }) {
@@ -1582,132 +3323,129 @@ function WalletButtonTemplate({
1582
3323
  ] });
1583
3324
  }
1584
3325
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "wallet-wrapper", ref: wrapperRef, children: [
1585
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-btn", style: { backgroundColor: accentColor }, onClick: onToggleOpen, children: [
1586
- cropWallet(walletAddress),
1587
- /* @__PURE__ */ jsxRuntime.jsx(
1588
- "svg",
1589
- {
1590
- className: `wallet-chevron${open ? " open" : ""}`,
1591
- viewBox: "0 0 12 12",
1592
- fill: "none",
1593
- stroke: "currentColor",
1594
- strokeWidth: "2",
1595
- strokeLinecap: "round",
1596
- strokeLinejoin: "round",
1597
- children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "2,4 6,8 10,4" })
1598
- }
1599
- )
1600
- ] }),
3326
+ /* @__PURE__ */ jsxRuntime.jsxs(
3327
+ "button",
3328
+ {
3329
+ className: "wallet-btn",
3330
+ style: { backgroundColor: accentColor },
3331
+ onClick: isInProgress ? void 0 : onToggleOpen,
3332
+ disabled: isInProgress,
3333
+ "aria-busy": isInProgress,
3334
+ children: [
3335
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "wallet-btn-label", children: cropWallet(walletAddress) }),
3336
+ isInProgress ? /* @__PURE__ */ jsxRuntime.jsxs(
3337
+ "svg",
3338
+ {
3339
+ className: "wallet-btn-spinner",
3340
+ viewBox: "0 0 12 12",
3341
+ width: "12",
3342
+ height: "12",
3343
+ fill: "none",
3344
+ "aria-hidden": true,
3345
+ children: [
3346
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "6", cy: "6", r: "4.5", stroke: "rgba(255,255,255,0.35)", strokeWidth: "1.5" }),
3347
+ /* @__PURE__ */ jsxRuntime.jsx(
3348
+ "circle",
3349
+ {
3350
+ cx: "6",
3351
+ cy: "6",
3352
+ r: "4.5",
3353
+ stroke: "white",
3354
+ strokeWidth: "1.5",
3355
+ strokeLinecap: "round",
3356
+ strokeDasharray: "14 9",
3357
+ transform: "rotate(-90 6 6)"
3358
+ }
3359
+ )
3360
+ ]
3361
+ }
3362
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
3363
+ "svg",
3364
+ {
3365
+ className: `wallet-chevron${open ? " open" : ""}`,
3366
+ viewBox: "0 0 12 12",
3367
+ fill: "none",
3368
+ stroke: "currentColor",
3369
+ strokeWidth: "2",
3370
+ strokeLinecap: "round",
3371
+ strokeLinejoin: "round",
3372
+ children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "2,4 6,8 10,4" })
3373
+ }
3374
+ )
3375
+ ]
3376
+ }
3377
+ ),
1601
3378
  open && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
3379
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onSend, children: [
3380
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3381
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
3382
+ /* @__PURE__ */ jsxRuntime.jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
3383
+ ] }),
3384
+ "Send"
3385
+ ] }),
3386
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onReceive, children: [
3387
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3388
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "8 17 12 21 16 17" }),
3389
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "12", x2: "12", y2: "21" }),
3390
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20.88 18.09A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.29" })
3391
+ ] }),
3392
+ "Receive"
3393
+ ] }),
3394
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "wallet-dropdown-divider" }),
1602
3395
  /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
1603
- /* @__PURE__ */ jsxRuntime.jsxs(
1604
- "svg",
1605
- {
1606
- width: "14",
1607
- height: "14",
1608
- viewBox: "0 0 24 24",
1609
- fill: "none",
1610
- stroke: "currentColor",
1611
- strokeWidth: "2",
1612
- strokeLinecap: "round",
1613
- strokeLinejoin: "round",
1614
- children: [
1615
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
1616
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
1617
- ]
1618
- }
1619
- ),
3396
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3397
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
3398
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
3399
+ ] }),
1620
3400
  copied ? "Copied!" : "Copy address"
1621
3401
  ] }),
1622
- /* @__PURE__ */ jsxRuntime.jsxs(
1623
- "button",
1624
- {
1625
- className: "wallet-dropdown-item",
1626
- style: { color: itemColor },
1627
- onClick: onWalletBalance,
1628
- children: [
1629
- /* @__PURE__ */ jsxRuntime.jsxs(
1630
- "svg",
1631
- {
1632
- width: "14",
1633
- height: "14",
1634
- viewBox: "0 0 24 24",
1635
- fill: "none",
1636
- stroke: "currentColor",
1637
- strokeWidth: "2",
1638
- strokeLinecap: "round",
1639
- strokeLinejoin: "round",
1640
- children: [
1641
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "4", width: "22", height: "16", rx: "2", ry: "2" }),
1642
- /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "16", cy: "12", r: "2" }),
1643
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M22 8H12" })
1644
- ]
1645
- }
1646
- ),
1647
- "Wallet balance"
1648
- ]
1649
- }
1650
- ),
1651
- /* @__PURE__ */ jsxRuntime.jsxs(
1652
- "button",
1653
- {
1654
- className: "wallet-dropdown-item",
1655
- style: { color: itemColor },
1656
- onClick: onTxHistory,
1657
- children: [
1658
- /* @__PURE__ */ jsxRuntime.jsxs(
1659
- "svg",
1660
- {
1661
- width: "14",
1662
- height: "14",
1663
- viewBox: "0 0 24 24",
1664
- fill: "none",
1665
- stroke: "currentColor",
1666
- strokeWidth: "2",
1667
- strokeLinecap: "round",
1668
- strokeLinejoin: "round",
1669
- children: [
1670
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1671
- /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "14,2 14,8 20,8" }),
1672
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
1673
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
1674
- /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "10,9 9,9 8,9" })
1675
- ]
1676
- }
1677
- ),
1678
- "Transaction history"
1679
- ]
1680
- }
1681
- ),
3402
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onWalletBalance, children: [
3403
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3404
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "4", width: "22", height: "16", rx: "2", ry: "2" }),
3405
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "16", cy: "12", r: "2" }),
3406
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M22 8H12" })
3407
+ ] }),
3408
+ "Wallet balance"
3409
+ ] }),
3410
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onTxHistory, children: [
3411
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3412
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
3413
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "14,2 14,8 20,8" }),
3414
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
3415
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
3416
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "10,9 9,9 8,9" })
3417
+ ] }),
3418
+ "Transaction history"
3419
+ ] }),
3420
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "wallet-dropdown-divider" }),
1682
3421
  /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
1683
- /* @__PURE__ */ jsxRuntime.jsxs(
1684
- "svg",
1685
- {
1686
- width: "14",
1687
- height: "14",
1688
- viewBox: "0 0 24 24",
1689
- fill: "none",
1690
- stroke: "currentColor",
1691
- strokeWidth: "2",
1692
- strokeLinecap: "round",
1693
- strokeLinejoin: "round",
1694
- children: [
1695
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
1696
- /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "16,17 21,12 16,7" }),
1697
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
1698
- ]
1699
- }
1700
- ),
3422
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3423
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
3424
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "16,17 21,12 16,7" }),
3425
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
3426
+ ] }),
1701
3427
  "Log out"
1702
3428
  ] })
1703
3429
  ] })
1704
3430
  ] });
1705
3431
  }
1706
3432
  function WalletButton() {
1707
- const { getClient, walletAddress, styles, openLoginModal, openTxHistoryModal, openWalletBalanceModal } = usePollar();
3433
+ const {
3434
+ getClient,
3435
+ walletAddress,
3436
+ styles,
3437
+ openLoginModal,
3438
+ openTxHistoryModal,
3439
+ openWalletBalanceModal,
3440
+ openSendModal,
3441
+ openReceiveModal,
3442
+ tx: transaction,
3443
+ walletType
3444
+ } = usePollar();
1708
3445
  const [open, setOpen] = react.useState(false);
1709
3446
  const [copied, setCopied] = react.useState(false);
1710
3447
  const wrapperRef = react.useRef(null);
3448
+ const isInProgress = transaction.step === "building" || transaction.step === "signing";
1711
3449
  const { theme = "light", accentColor = "#005DB4" } = styles;
1712
3450
  const isDark = theme === "dark";
1713
3451
  const dropdownBg = isDark ? "#18181b" : "#fff";
@@ -1740,6 +3478,14 @@ function WalletButton() {
1740
3478
  setOpen(false);
1741
3479
  openTxHistoryModal();
1742
3480
  }
3481
+ function handleSend() {
3482
+ setOpen(false);
3483
+ openSendModal();
3484
+ }
3485
+ function handleReceive() {
3486
+ setOpen(false);
3487
+ openReceiveModal();
3488
+ }
1743
3489
  return /* @__PURE__ */ jsxRuntime.jsx(
1744
3490
  WalletButtonTemplate,
1745
3491
  {
@@ -1751,10 +3497,14 @@ function WalletButton() {
1751
3497
  dropdownBorder,
1752
3498
  itemColor,
1753
3499
  wrapperRef,
3500
+ isInProgress,
3501
+ walletType,
1754
3502
  onToggleOpen: () => setOpen((v) => !v),
1755
3503
  onCopy: handleCopy,
1756
3504
  onWalletBalance: handleWalletBalance,
1757
3505
  onTxHistory: handleTxHistory,
3506
+ onSend: handleSend,
3507
+ onReceive: handleReceive,
1758
3508
  onLogout: handleLogout,
1759
3509
  onLogin: openLoginModal
1760
3510
  }
@@ -1768,9 +3518,16 @@ exports.LoginModalTemplate = LoginModalTemplate;
1768
3518
  exports.PollarProvider = PollarProvider;
1769
3519
  exports.RampWidget = RampWidget;
1770
3520
  exports.RampWidgetTemplate = RampWidgetTemplate;
3521
+ exports.ReceiveModal = ReceiveModal;
3522
+ exports.ReceiveModalTemplate = ReceiveModalTemplate;
1771
3523
  exports.RouteDisplay = RouteDisplay;
3524
+ exports.SendModal = SendModal;
3525
+ exports.SendModalTemplate = SendModalTemplate;
3526
+ exports.SessionsModal = SessionsModal;
3527
+ exports.SessionsModalTemplate = SessionsModalTemplate;
1772
3528
  exports.TransactionModalTemplate = TransactionModalTemplate;
1773
3529
  exports.TxHistoryModalTemplate = TxHistoryModalTemplate;
3530
+ exports.TxStatusView = TxStatusView;
1774
3531
  exports.WalletBalanceModal = WalletBalanceModal;
1775
3532
  exports.WalletBalanceModalTemplate = WalletBalanceModalTemplate;
1776
3533
  exports.WalletButton = WalletButton;