@pollar/react 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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.6.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" }),
@@ -1031,14 +2151,7 @@ function TransactionModalTemplate({
1031
2151
  ]
1032
2152
  }
1033
2153
  ),
1034
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsxRuntime.jsx(
1035
- "img",
1036
- {
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"
1040
- }
1041
- ) })
2154
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: walletImg, alt: walletAlt, className: "pollar-tx-wallet-img" }) })
1042
2155
  ] }),
1043
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" }),
1044
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" })
@@ -1103,19 +2216,369 @@ function TransactionModalTemplate({
1103
2216
  ] })
1104
2217
  ] })
1105
2218
  ] }),
1106
- isSuccess && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onClose, children: "Done" }),
2219
+ isSuccess && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onDone, children: "Done" }),
1107
2220
  /* @__PURE__ */ jsxRuntime.jsx(
1108
2221
  ModalStatusBanner,
1109
2222
  {
1110
2223
  message: STATUS_MESSAGES[transaction.step],
1111
2224
  status: isError ? "ERROR" : isSigning || transaction.step === "building" ? "LOADING" : isSuccess ? "SUCCESS" : "NONE"
1112
2225
  }
1113
- ),
1114
- /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
2226
+ )
1115
2227
  ] });
1116
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 TransactionModalTemplate({
2505
+ theme,
2506
+ accentColor,
2507
+ transaction,
2508
+ showXdr,
2509
+ copied,
2510
+ explorerUrl,
2511
+ walletType,
2512
+ onClose,
2513
+ onSignAndSend,
2514
+ onToggleXdr,
2515
+ onCopyHash,
2516
+ onRetry
2517
+ }) {
2518
+ const isDark = theme === "dark";
2519
+ const cssVars = {
2520
+ "--pollar-accent": accentColor,
2521
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
2522
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
2523
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
2524
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
2525
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2526
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2527
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
2528
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
2529
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2530
+ "--pollar-buttons-border-radius": "6px",
2531
+ "--pollar-buttons-height": "44px",
2532
+ "--pollar-input-height": "44px",
2533
+ "--pollar-input-border-radius": "0.5rem",
2534
+ "--pollar-card-border-radius": "10px"
2535
+ };
2536
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2537
+ "div",
2538
+ {
2539
+ className: "pollar-modal-card pollar-tx-modal",
2540
+ "data-theme": theme,
2541
+ style: cssVars,
2542
+ onClick: (e) => e.stopPropagation(),
2543
+ children: [
2544
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Transaction" }) }),
2545
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(
2546
+ "svg",
2547
+ {
2548
+ width: "18",
2549
+ height: "18",
2550
+ viewBox: "0 0 24 24",
2551
+ fill: "none",
2552
+ stroke: "currentColor",
2553
+ strokeWidth: "2.5",
2554
+ strokeLinecap: "round",
2555
+ strokeLinejoin: "round",
2556
+ "aria-hidden": true,
2557
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" })
2558
+ }
2559
+ ) }),
2560
+ /* @__PURE__ */ jsxRuntime.jsx(
2561
+ TxStatusView,
2562
+ {
2563
+ transaction,
2564
+ showXdr,
2565
+ copied,
2566
+ explorerUrl,
2567
+ walletType,
2568
+ onSignAndSend,
2569
+ onToggleXdr,
2570
+ onCopyHash,
2571
+ onRetry,
2572
+ onDone: onClose
2573
+ }
2574
+ ),
2575
+ /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
2576
+ ]
2577
+ }
2578
+ );
2579
+ }
1117
2580
  function TransactionModal({ onClose }) {
1118
- const { getClient, styles, transaction, network, walletType } = usePollar();
2581
+ const { getClient, styles, tx: transaction, network, walletType } = usePollar();
1119
2582
  const { theme = "light", accentColor = "#005DB4" } = styles;
1120
2583
  const [showXdr, setShowXdr] = react.useState(false);
1121
2584
  const [copied, setCopied] = react.useState(false);
@@ -1286,10 +2749,13 @@ function TxHistoryModal({ onClose }) {
1286
2749
  const { getClient, styles, txHistory } = usePollar();
1287
2750
  const { theme = "light", accentColor = "#005DB4" } = styles;
1288
2751
  const [offset, setOffset] = react.useState(0);
1289
- function load(nextOffset) {
2752
+ const load = react.useCallback((nextOffset) => {
1290
2753
  setOffset(nextOffset);
1291
2754
  void getClient().fetchTxHistory({ limit: PAGE_SIZE2, offset: nextOffset });
1292
- }
2755
+ }, [getClient]);
2756
+ react.useEffect(() => {
2757
+ load(0);
2758
+ }, [load]);
1293
2759
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
1294
2760
  TxHistoryModalTemplate,
1295
2761
  {
@@ -1304,7 +2770,7 @@ function TxHistoryModal({ onClose }) {
1304
2770
  }
1305
2771
  ) });
1306
2772
  }
1307
- function formatBalance(balance) {
2773
+ function formatBalance2(balance) {
1308
2774
  const n = parseFloat(balance);
1309
2775
  return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
1310
2776
  }
@@ -1317,9 +2783,9 @@ function BalanceItem({ record }) {
1317
2783
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-item", children: [
1318
2784
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-asset", children: record.code }),
1319
2785
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-amounts", children: [
1320
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-amount", children: formatBalance(record.balance) }),
2786
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-amount", children: formatBalance2(record.balance) }),
1321
2787
  balanceDiffers && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-bal-available", children: [
1322
- formatBalance(record.available),
2788
+ formatBalance2(record.available),
1323
2789
  " available"
1324
2790
  ] })
1325
2791
  ] })
@@ -1392,11 +2858,11 @@ function WalletBalanceModalTemplate({
1392
2858
  ] });
1393
2859
  }
1394
2860
  function WalletBalanceModal({ onClose }) {
1395
- const { walletBalance, refreshBalance, walletAddress, styles } = usePollar();
2861
+ const { walletBalance, refreshWalletBalance, walletAddress, styles } = usePollar();
1396
2862
  const { theme = "light", accentColor = "#005DB4" } = styles;
1397
2863
  react.useEffect(() => {
1398
- void refreshBalance();
1399
- }, []);
2864
+ void refreshWalletBalance();
2865
+ }, [refreshWalletBalance]);
1400
2866
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
1401
2867
  WalletBalanceModalTemplate,
1402
2868
  {
@@ -1404,7 +2870,7 @@ function WalletBalanceModal({ onClose }) {
1404
2870
  accentColor,
1405
2871
  walletBalance,
1406
2872
  walletAddress,
1407
- onRefresh: () => refreshBalance(),
2873
+ onRefresh: () => refreshWalletBalance(),
1408
2874
  onClose
1409
2875
  }
1410
2876
  ) });
@@ -1429,6 +2895,8 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1429
2895
  const [walletBalance, setWalletBalance] = react.useState({ step: "idle" });
1430
2896
  const [remoteConfig, setRemoteConfig] = react.useState(emptyResponse);
1431
2897
  const [styles, setStyles] = react.useState(propStyles ?? {});
2898
+ const propStylesRef = react.useRef(propStyles);
2899
+ propStylesRef.current = propStyles;
1432
2900
  react.useEffect(() => {
1433
2901
  return pollarClient.onTransactionStateChange(setTransaction);
1434
2902
  }, [pollarClient]);
@@ -1453,59 +2921,75 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1453
2921
  });
1454
2922
  }, [pollarClient]);
1455
2923
  react.useEffect(() => {
2924
+ const propStyles2 = propStylesRef.current;
1456
2925
  fetchRemoteConfig(pollarClient).then((fetched) => {
1457
2926
  setRemoteConfig(fetched);
1458
2927
  setStyles({
1459
2928
  ...fetched.styles,
1460
- ...propStyles,
1461
- providers: { ...fetched.styles?.providers, ...propStyles?.providers }
2929
+ ...propStyles2,
2930
+ providers: { ...fetched.styles?.providers, ...propStyles2?.providers }
1462
2931
  });
1463
2932
  }).catch(() => {
1464
- setStyles(propStyles ?? {});
2933
+ setStyles(propStyles2 ?? {});
1465
2934
  });
1466
2935
  }, [pollarClient]);
1467
- react.useEffect(() => {
1468
- if (transaction.step !== "idle") {
1469
- setTransactionModalOpen(true);
1470
- }
1471
- }, [transaction.step]);
1472
2936
  const [loginModalOpen, setLoginModalOpen] = react.useState(false);
1473
2937
  const [transactionModalOpen, setTransactionModalOpen] = react.useState(false);
1474
2938
  const [kycModalOpen, setKycModalOpen] = react.useState(false);
1475
2939
  const [kycModalOptions, setKycModalOptions] = react.useState({});
1476
- const [rampWidgetOpen, setRampWidgetOpen] = react.useState(false);
2940
+ const [rampModalOpen, setRampModalOpen] = react.useState(false);
1477
2941
  const [txHistoryModalOpen, setTxHistoryModalOpen] = react.useState(false);
1478
2942
  const [walletBalanceModalOpen, setWalletBalanceModalOpen] = react.useState(false);
2943
+ const [sendModalOpen, setSendModalOpen] = react.useState(false);
2944
+ const [receiveModalOpen, setReceiveModalOpen] = react.useState(false);
2945
+ const adaptersRef = react.useRef(adapters);
2946
+ adaptersRef.current = adapters;
2947
+ const walletAddress = sessionState?.data?.providers?.wallet?.address || sessionState?.wallet?.publicKey || "";
2948
+ const getClient = react.useCallback(() => pollarClient, [pollarClient]);
2949
+ const refreshWalletBalance = react.useCallback(() => pollarClient.refreshBalance(walletAddress), [pollarClient, walletAddress]);
1479
2950
  const contextValue = react.useMemo(
1480
2951
  () => ({
1481
- walletAddress: sessionState?.data?.providers?.wallet?.address || sessionState?.wallet?.publicKey || "",
1482
- getClient: () => pollarClient,
1483
- transaction,
2952
+ // session
2953
+ walletAddress,
2954
+ isAuthenticated: !!walletAddress,
2955
+ walletType: pollarClient.getWalletType(),
2956
+ // client
2957
+ getClient,
2958
+ // auth
1484
2959
  login: (options) => pollarClient.login(options),
1485
2960
  logout: () => pollarClient.logout(),
1486
- isAuthenticated: !!sessionState?.wallet?.publicKey,
2961
+ openLoginModal: () => setLoginModalOpen(true),
2962
+ // transactions
2963
+ tx: transaction,
1487
2964
  buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
1488
2965
  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),
2966
+ openTxModal: () => setTransactionModalOpen(true),
2967
+ // tx history
1497
2968
  txHistory,
1498
2969
  openTxHistoryModal: () => setTxHistoryModalOpen(true),
1499
- openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
2970
+ // wallet balance
1500
2971
  walletBalance,
1501
- refreshBalance: (publicKey) => pollarClient.refreshBalance(publicKey),
2972
+ refreshWalletBalance,
2973
+ openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
2974
+ // send / receive
2975
+ openSendModal: () => setSendModalOpen(true),
2976
+ openReceiveModal: () => setReceiveModalOpen(true),
2977
+ // network
1502
2978
  network: networkState.step === "connected" ? networkState.network : "testnet",
1503
2979
  setNetwork: (network) => pollarClient.setNetwork(network),
1504
- config: remoteConfig,
2980
+ // kyc
2981
+ openKycModal: (options = {}) => {
2982
+ setKycModalOptions(options);
2983
+ setKycModalOpen(true);
2984
+ },
2985
+ // ramp
2986
+ openRampModal: () => setRampModalOpen(true),
2987
+ // config
2988
+ appConfig: remoteConfig,
1505
2989
  styles,
1506
- adapters
2990
+ adapters: adaptersRef.current
1507
2991
  }),
1508
- [sessionState, remoteConfig, styles, pollarClient, transaction, txHistory, networkState, walletBalance]
2992
+ [walletAddress, pollarClient, getClient, transaction, txHistory, walletBalance, refreshWalletBalance, networkState, remoteConfig, styles]
1509
2993
  );
1510
2994
  return /* @__PURE__ */ jsxRuntime.jsxs(PollarContext.Provider, { value: contextValue, children: [
1511
2995
  children,
@@ -1520,9 +3004,11 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1520
3004
  ...kycModalOptions.onApproved !== void 0 && { onApproved: kycModalOptions.onApproved }
1521
3005
  }
1522
3006
  ) }),
1523
- rampWidgetOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setRampWidgetOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(RampWidget, { onClose: () => setRampWidgetOpen(false) }) }),
3007
+ rampModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setRampModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(RampWidget, { onClose: () => setRampModalOpen(false) }) }),
1524
3008
  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) }) })
3009
+ walletBalanceModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) }),
3010
+ sendModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }),
3011
+ receiveModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false) }) })
1526
3012
  ] });
1527
3013
  }
1528
3014
  function usePollar() {
@@ -1568,10 +3054,13 @@ function WalletButtonTemplate({
1568
3054
  dropdownBorder,
1569
3055
  itemColor,
1570
3056
  wrapperRef,
3057
+ isInProgress,
1571
3058
  onToggleOpen,
1572
3059
  onCopy,
1573
3060
  onWalletBalance,
1574
3061
  onTxHistory,
3062
+ onSend,
3063
+ onReceive,
1575
3064
  onLogout,
1576
3065
  onLogin
1577
3066
  }) {
@@ -1582,132 +3071,129 @@ function WalletButtonTemplate({
1582
3071
  ] });
1583
3072
  }
1584
3073
  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
- ] }),
3074
+ /* @__PURE__ */ jsxRuntime.jsxs(
3075
+ "button",
3076
+ {
3077
+ className: "wallet-btn",
3078
+ style: { backgroundColor: accentColor },
3079
+ onClick: isInProgress ? void 0 : onToggleOpen,
3080
+ disabled: isInProgress,
3081
+ "aria-busy": isInProgress,
3082
+ children: [
3083
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "wallet-btn-label", children: cropWallet(walletAddress) }),
3084
+ isInProgress ? /* @__PURE__ */ jsxRuntime.jsxs(
3085
+ "svg",
3086
+ {
3087
+ className: "wallet-btn-spinner",
3088
+ viewBox: "0 0 12 12",
3089
+ width: "12",
3090
+ height: "12",
3091
+ fill: "none",
3092
+ "aria-hidden": true,
3093
+ children: [
3094
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "6", cy: "6", r: "4.5", stroke: "rgba(255,255,255,0.35)", strokeWidth: "1.5" }),
3095
+ /* @__PURE__ */ jsxRuntime.jsx(
3096
+ "circle",
3097
+ {
3098
+ cx: "6",
3099
+ cy: "6",
3100
+ r: "4.5",
3101
+ stroke: "white",
3102
+ strokeWidth: "1.5",
3103
+ strokeLinecap: "round",
3104
+ strokeDasharray: "14 9",
3105
+ transform: "rotate(-90 6 6)"
3106
+ }
3107
+ )
3108
+ ]
3109
+ }
3110
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
3111
+ "svg",
3112
+ {
3113
+ className: `wallet-chevron${open ? " open" : ""}`,
3114
+ viewBox: "0 0 12 12",
3115
+ fill: "none",
3116
+ stroke: "currentColor",
3117
+ strokeWidth: "2",
3118
+ strokeLinecap: "round",
3119
+ strokeLinejoin: "round",
3120
+ children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "2,4 6,8 10,4" })
3121
+ }
3122
+ )
3123
+ ]
3124
+ }
3125
+ ),
1601
3126
  open && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
3127
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onSend, children: [
3128
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3129
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
3130
+ /* @__PURE__ */ jsxRuntime.jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
3131
+ ] }),
3132
+ "Send"
3133
+ ] }),
3134
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onReceive, children: [
3135
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3136
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "8 17 12 21 16 17" }),
3137
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "12", x2: "12", y2: "21" }),
3138
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20.88 18.09A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.29" })
3139
+ ] }),
3140
+ "Receive"
3141
+ ] }),
3142
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "wallet-dropdown-divider" }),
1602
3143
  /* @__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
- ),
3144
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3145
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
3146
+ /* @__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" })
3147
+ ] }),
1620
3148
  copied ? "Copied!" : "Copy address"
1621
3149
  ] }),
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
- ),
3150
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onWalletBalance, children: [
3151
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3152
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "4", width: "22", height: "16", rx: "2", ry: "2" }),
3153
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "16", cy: "12", r: "2" }),
3154
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M22 8H12" })
3155
+ ] }),
3156
+ "Wallet balance"
3157
+ ] }),
3158
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onTxHistory, children: [
3159
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3160
+ /* @__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" }),
3161
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "14,2 14,8 20,8" }),
3162
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
3163
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
3164
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "10,9 9,9 8,9" })
3165
+ ] }),
3166
+ "Transaction history"
3167
+ ] }),
3168
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "wallet-dropdown-divider" }),
1682
3169
  /* @__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
- ),
3170
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3171
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
3172
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "16,17 21,12 16,7" }),
3173
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
3174
+ ] }),
1701
3175
  "Log out"
1702
3176
  ] })
1703
3177
  ] })
1704
3178
  ] });
1705
3179
  }
1706
3180
  function WalletButton() {
1707
- const { getClient, walletAddress, styles, openLoginModal, openTxHistoryModal, openWalletBalanceModal } = usePollar();
3181
+ const {
3182
+ getClient,
3183
+ walletAddress,
3184
+ styles,
3185
+ openLoginModal,
3186
+ openTxHistoryModal,
3187
+ openWalletBalanceModal,
3188
+ openSendModal,
3189
+ openReceiveModal,
3190
+ tx: transaction,
3191
+ walletType
3192
+ } = usePollar();
1708
3193
  const [open, setOpen] = react.useState(false);
1709
3194
  const [copied, setCopied] = react.useState(false);
1710
3195
  const wrapperRef = react.useRef(null);
3196
+ const isInProgress = transaction.step === "building" || transaction.step === "signing";
1711
3197
  const { theme = "light", accentColor = "#005DB4" } = styles;
1712
3198
  const isDark = theme === "dark";
1713
3199
  const dropdownBg = isDark ? "#18181b" : "#fff";
@@ -1740,6 +3226,14 @@ function WalletButton() {
1740
3226
  setOpen(false);
1741
3227
  openTxHistoryModal();
1742
3228
  }
3229
+ function handleSend() {
3230
+ setOpen(false);
3231
+ openSendModal();
3232
+ }
3233
+ function handleReceive() {
3234
+ setOpen(false);
3235
+ openReceiveModal();
3236
+ }
1743
3237
  return /* @__PURE__ */ jsxRuntime.jsx(
1744
3238
  WalletButtonTemplate,
1745
3239
  {
@@ -1751,10 +3245,14 @@ function WalletButton() {
1751
3245
  dropdownBorder,
1752
3246
  itemColor,
1753
3247
  wrapperRef,
3248
+ isInProgress,
3249
+ walletType,
1754
3250
  onToggleOpen: () => setOpen((v) => !v),
1755
3251
  onCopy: handleCopy,
1756
3252
  onWalletBalance: handleWalletBalance,
1757
3253
  onTxHistory: handleTxHistory,
3254
+ onSend: handleSend,
3255
+ onReceive: handleReceive,
1758
3256
  onLogout: handleLogout,
1759
3257
  onLogin: openLoginModal
1760
3258
  }
@@ -1768,9 +3266,14 @@ exports.LoginModalTemplate = LoginModalTemplate;
1768
3266
  exports.PollarProvider = PollarProvider;
1769
3267
  exports.RampWidget = RampWidget;
1770
3268
  exports.RampWidgetTemplate = RampWidgetTemplate;
3269
+ exports.ReceiveModal = ReceiveModal;
3270
+ exports.ReceiveModalTemplate = ReceiveModalTemplate;
1771
3271
  exports.RouteDisplay = RouteDisplay;
3272
+ exports.SendModal = SendModal;
3273
+ exports.SendModalTemplate = SendModalTemplate;
1772
3274
  exports.TransactionModalTemplate = TransactionModalTemplate;
1773
3275
  exports.TxHistoryModalTemplate = TxHistoryModalTemplate;
3276
+ exports.TxStatusView = TxStatusView;
1774
3277
  exports.WalletBalanceModal = WalletBalanceModal;
1775
3278
  exports.WalletBalanceModalTemplate = WalletBalanceModalTemplate;
1776
3279
  exports.WalletButton = WalletButton;