@pollar/react 0.5.2 → 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.2"
1033
+ "0.6.0"
42
1034
  ] })
43
1035
  ] })
44
1036
  ] });
@@ -98,15 +1090,25 @@ function KycModalTemplate({
98
1090
  const isDark = theme === "dark";
99
1091
  const cssVars = {
100
1092
  "--pollar-accent": accentColor,
101
- "--pollar-buttons-border-radius": "6px",
102
- "--pollar-buttons-height": "44px",
103
1093
  "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
104
1094
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
105
1095
  "--pollar-text": isDark ? "#ffffff" : "#111827",
106
1096
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
107
- "--pollar-input-bg": isDark ? "#374151" : "#f9fafb"
1097
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
1098
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
1099
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
1100
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
1101
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
1102
+ "--pollar-buttons-border-radius": "6px",
1103
+ "--pollar-buttons-height": "44px",
1104
+ "--pollar-input-height": "44px",
1105
+ "--pollar-input-border-radius": "0.5rem",
1106
+ "--pollar-card-border-radius": "10px",
1107
+ "--pollar-modal-padding": "2rem",
1108
+ "--pollar-modal-heading-size": "1.375rem",
1109
+ "--pollar-modal-subtitle-size": "0.9rem"
108
1110
  };
109
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-kyc-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
1111
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-kyc-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
110
1112
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-kyc-header", children: [
111
1113
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-kyc-title", children: "Identity verification" }),
112
1114
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "pollar-kyc-subtitle", children: [
@@ -161,8 +1163,8 @@ function KycModal({ onClose, country = "MX", level = "basic", onApproved }) {
161
1163
  const { theme = "light", accentColor = "#005DB4" } = styles;
162
1164
  react.useEffect(() => {
163
1165
  setIsLoading(true);
164
- client.getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
165
- }, [country]);
1166
+ getClient().getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
1167
+ }, [getClient, country]);
166
1168
  async function handleSelectProvider(provider) {
167
1169
  setSelectedProvider(provider);
168
1170
  setIsLoading(true);
@@ -376,16 +1378,23 @@ function LoginModalTemplate({
376
1378
  const enabledSocial = Object.entries(providers).filter(([, enabled]) => enabled);
377
1379
  const cssVars = {
378
1380
  "--pollar-accent": accentColor,
379
- "--pollar-buttons-border-radius": "6px",
380
- "--pollar-buttons-height": "44px",
381
1381
  "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
382
1382
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
383
1383
  "--pollar-text": isDark ? "#ffffff" : "#111827",
384
1384
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
385
- "--pollar-input-bg": isDark ? "#374151" : "#ffffff",
1385
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
386
1386
  "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
387
1387
  "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
388
- "--pollar-error-text": isDark ? "#f87171" : "#dc2626"
1388
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
1389
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
1390
+ "--pollar-buttons-border-radius": "6px",
1391
+ "--pollar-buttons-height": "44px",
1392
+ "--pollar-input-height": "44px",
1393
+ "--pollar-input-border-radius": "0.5rem",
1394
+ "--pollar-card-border-radius": "10px",
1395
+ "--pollar-modal-padding": "2rem",
1396
+ "--pollar-modal-heading-size": "1.375rem",
1397
+ "--pollar-modal-subtitle-size": "0.9rem"
389
1398
  };
390
1399
  const status = authStateToStatus(authState.step);
391
1400
  const isLoading = status === "LOADING";
@@ -393,7 +1402,7 @@ function LoginModalTemplate({
393
1402
  const awaitingEmailCode = authState.step === "entering_code" || authState.step === "verifying_email_code" || isEmailCodeError;
394
1403
  const statusMessage = authState.step === "error" ? authState.message : AUTH_STATE_MESSAGES[authState.step];
395
1404
  const BackButton = ({ onClick }) => /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-back-btn", onClick, "aria-label": "Back", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 19l-7-7 7-7" }) }) });
396
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
1405
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
397
1406
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onCancel, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" }) }) }),
398
1407
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-header", children: [
399
1408
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-logo-wrap", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoUrl ?? LOGO_POLLAR, alt: "Logo", className: "pollar-logo" }) }),
@@ -448,7 +1457,7 @@ function LoginModalTemplate({
448
1457
  onKeyDown: (e) => e.key === "Enter" && onEmailSubmit?.()
449
1458
  }
450
1459
  ),
451
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", disabled: isLoading || !email, className: "pollar-submit-btn", onClick: onEmailSubmit, children: "Submit" })
1460
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", disabled: isLoading || !email, className: "pollar-btn-primary", style: { marginTop: "0.75rem", width: "100%" }, onClick: onEmailSubmit, children: "Submit" })
452
1461
  ] }),
453
1462
  emailEnabled && enabledSocial.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-divider", children: [
454
1463
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-divider-line" }),
@@ -486,10 +1495,12 @@ function LoginModalTemplate({
486
1495
  }
487
1496
  function LoginModal({ onClose }) {
488
1497
  const [email, setEmail] = react.useState("");
489
- const { getClient, styles, config } = usePollar();
1498
+ const { getClient, styles, appConfig: config } = usePollar();
490
1499
  const [authState, setAuthState] = react.useState(() => getClient().getAuthState());
491
1500
  const [codeInputKey, setCodeInputKey] = react.useState(0);
492
1501
  const pendingEmail = react.useRef(null);
1502
+ const onCloseRef = react.useRef(onClose);
1503
+ onCloseRef.current = onClose;
493
1504
  react.useEffect(() => {
494
1505
  return getClient().onAuthStateChange((next) => {
495
1506
  setAuthState(next);
@@ -501,10 +1512,10 @@ function LoginModal({ onClose }) {
501
1512
  setCodeInputKey((k) => k + 1);
502
1513
  }
503
1514
  if (next.step === "authenticated") {
504
- setTimeout(onClose, 1e3);
1515
+ setTimeout(onCloseRef.current, 1e3);
505
1516
  }
506
1517
  });
507
- }, []);
1518
+ }, [getClient]);
508
1519
  const { theme = "light", accentColor = "#005DB4", logoUrl, emailEnabled, embeddedWallets, providers } = styles;
509
1520
  function handleClose() {
510
1521
  setEmail("");
@@ -566,67 +1577,227 @@ function LoginModal({ onClose }) {
566
1577
  }
567
1578
  ) });
568
1579
  }
569
- var RAIL_LABELS = {
570
- SPEI: "SPEI (Mexico)",
571
- PIX: "PIX (Brazil)",
572
- PSE: "PSE (Colombia)",
573
- ACH: "ACH (US)"
574
- };
575
- function RouteDisplay({ quote, onSelect }) {
576
- return /* @__PURE__ */ jsxRuntime.jsxs(
577
- "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,
578
1617
  {
579
- className: "pollar-ramp-route-card",
580
- "data-recommended": quote.recommended,
581
- role: "button",
582
- tabIndex: 0,
583
- onClick: () => onSelect(quote),
584
- onKeyDown: (e) => e.key === "Enter" && onSelect(quote),
585
- children: [
586
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-route-left", children: [
587
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-route-provider", children: quote.provider }),
588
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-ramp-route-meta", children: [
589
- RAIL_LABELS[quote.rail] ?? quote.rail,
590
- " \xB7 ",
591
- quote.protocol,
592
- " \xB7 ",
593
- quote.estimatedTime
594
- ] })
595
- ] }),
596
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-route-right", children: [
597
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-ramp-route-fee", children: [
598
- quote.fee,
599
- "% fee"
600
- ] }),
601
- quote.recommended && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-ramp-route-badge", children: "Best rate" })
602
- ] })
603
- ]
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
604
1626
  }
605
1627
  );
606
- }
607
- var LOADING_STEPS = ["Detecting your country\u2026", "Consulting providers\u2026", "Route found!"];
608
- var COUNTRY_CURRENCIES = {
609
- MX: "MXN",
610
- BR: "BRL",
611
- CO: "COP",
612
- CL: "CLP",
613
- PE: "PEN",
614
- AR: "ARS"
615
- };
616
- function RampWidgetTemplate({
1628
+ });
1629
+ function ReceiveModalTemplate({
617
1630
  theme,
618
1631
  accentColor,
619
- step,
620
- direction,
621
- amount,
622
- currency,
623
- country,
624
- quotes,
625
- paymentInstructions,
626
- isLoading,
627
- onDirectionChange,
628
- onAmountChange,
629
- onCurrencyChange,
1632
+ walletAddress,
1633
+ copied,
1634
+ onCopy,
1635
+ onClose
1636
+ }) {
1637
+ const isDark = theme === "dark";
1638
+ const cssVars = {
1639
+ "--pollar-accent": accentColor,
1640
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
1641
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
1642
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
1643
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
1644
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
1645
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
1646
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
1647
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
1648
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
1649
+ "--pollar-buttons-border-radius": "6px",
1650
+ "--pollar-buttons-height": "44px",
1651
+ "--pollar-input-height": "44px",
1652
+ "--pollar-input-border-radius": "0.5rem",
1653
+ "--pollar-card-border-radius": "10px"
1654
+ };
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,
630
1801
  onCountryChange,
631
1802
  onFindRoute,
632
1803
  onSelectQuote,
@@ -636,13 +1807,23 @@ function RampWidgetTemplate({
636
1807
  const isDark = theme === "dark";
637
1808
  const cssVars = {
638
1809
  "--pollar-accent": accentColor,
639
- "--pollar-buttons-border-radius": "6px",
640
- "--pollar-buttons-height": "44px",
641
1810
  "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
642
1811
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
643
1812
  "--pollar-text": isDark ? "#ffffff" : "#111827",
644
1813
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
645
- "--pollar-input-bg": isDark ? "#374151" : "#f9fafb"
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"
646
1827
  };
647
1828
  const stepTitle = {
648
1829
  input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
@@ -656,7 +1837,7 @@ function RampWidgetTemplate({
656
1837
  select_route: "All prices include fees",
657
1838
  payment_instructions: "Send the exact amount to complete your transaction"
658
1839
  };
659
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
1840
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-ramp-modal", style: cssVars, onClick: (e) => e.stopPropagation(), children: [
660
1841
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-ramp-header", children: [
661
1842
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-ramp-title", children: stepTitle[step] }),
662
1843
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-ramp-subtitle", children: stepSubtitle[step] })
@@ -878,33 +2059,18 @@ var STATUS_MESSAGES = {
878
2059
  success: "Transaction sent successfully",
879
2060
  error: "Transaction failed"
880
2061
  };
881
- function TransactionModalTemplate({
882
- theme,
883
- accentColor,
2062
+ function TxStatusView({
884
2063
  transaction,
885
2064
  showXdr,
886
2065
  copied,
887
2066
  explorerUrl,
888
2067
  walletType,
889
- onClose,
890
2068
  onSignAndSend,
891
2069
  onToggleXdr,
892
2070
  onCopyHash,
893
- onRetry
2071
+ onRetry,
2072
+ onDone
894
2073
  }) {
895
- const isDark = theme === "dark";
896
- const cssVars = {
897
- "--pollar-accent": accentColor,
898
- "--pollar-buttons-border-radius": "8px",
899
- "--pollar-buttons-height": "44px",
900
- "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
901
- "--pollar-border": isDark ? "#374151" : "#e5e7eb",
902
- "--pollar-text": isDark ? "#ffffff" : "#111827",
903
- "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
904
- "--pollar-input-bg": isDark ? "#374151" : "rgba(0,0,0,0.04)",
905
- "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
906
- "--pollar-success-text": isDark ? "#4ade80" : "#16a34a"
907
- };
908
2074
  const buildData = "buildData" in transaction ? transaction.buildData : null;
909
2075
  const hash = transaction.step === "success" ? transaction.hash : null;
910
2076
  const errorDetails = transaction.step === "error" ? transaction.details ?? null : null;
@@ -913,23 +2079,9 @@ function TransactionModalTemplate({
913
2079
  const isSuccess = transaction.step === "success";
914
2080
  const isError = transaction.step === "error";
915
2081
  const showDetails = buildData !== null && (isBuilt || isSigning || isSuccess);
916
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
917
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-header", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Transaction" }) }),
918
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "pollar-close-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsxRuntime.jsx(
919
- "svg",
920
- {
921
- width: "18",
922
- height: "18",
923
- viewBox: "0 0 24 24",
924
- fill: "none",
925
- stroke: "currentColor",
926
- strokeWidth: "2.5",
927
- strokeLinecap: "round",
928
- strokeLinejoin: "round",
929
- "aria-hidden": true,
930
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6L6 18M6 6l12 12" })
931
- }
932
- ) }),
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: [
933
2085
  showDetails && buildData && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
934
2086
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-tx-summary", children: [
935
2087
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pollar-tx-summary-title", children: "Details" }),
@@ -999,14 +2151,7 @@ function TransactionModalTemplate({
999
2151
  ]
1000
2152
  }
1001
2153
  ),
1002
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsxRuntime.jsx(
1003
- "img",
1004
- {
1005
- src: walletType === core.WalletType.FREIGHTER ? LOGO_FREIGHTER : walletType === core.WalletType.ALBEDO ? LOGO_ALBEDO : LOGO_POLLAR,
1006
- alt: walletType === core.WalletType.FREIGHTER ? "Freighter" : walletType === core.WalletType.ALBEDO ? "Albedo" : "Pollar",
1007
- className: "pollar-tx-wallet-img"
1008
- }
1009
- ) })
2154
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: walletImg, alt: walletAlt, className: "pollar-tx-wallet-img" }) })
1010
2155
  ] }),
1011
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" }),
1012
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" })
@@ -1071,25 +2216,375 @@ function TransactionModalTemplate({
1071
2216
  ] })
1072
2217
  ] })
1073
2218
  ] }),
1074
- 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" }),
1075
2220
  /* @__PURE__ */ jsxRuntime.jsx(
1076
2221
  ModalStatusBanner,
1077
2222
  {
1078
2223
  message: STATUS_MESSAGES[transaction.step],
1079
2224
  status: isError ? "ERROR" : isSigning || transaction.step === "building" ? "LOADING" : isSuccess ? "SUCCESS" : "NONE"
1080
2225
  }
1081
- ),
1082
- /* @__PURE__ */ jsxRuntime.jsx(PollarModalFooter, {})
2226
+ )
1083
2227
  ] });
1084
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
+ }
1085
2580
  function TransactionModal({ onClose }) {
1086
- const { getClient, styles, transaction, network, walletType } = usePollar();
2581
+ const { getClient, styles, tx: transaction, network, walletType } = usePollar();
1087
2582
  const { theme = "light", accentColor = "#005DB4" } = styles;
1088
2583
  const [showXdr, setShowXdr] = react.useState(false);
1089
2584
  const [copied, setCopied] = react.useState(false);
1090
2585
  const hash = transaction.step === "success" ? transaction.hash : null;
1091
2586
  const buildData = "buildData" in transaction ? transaction.buildData : null;
1092
- const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : "public";
2587
+ const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
1093
2588
  const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
1094
2589
  function handleSignAndSend() {
1095
2590
  if (transaction.step === "built") {
@@ -1146,15 +2641,20 @@ function TxHistoryModalTemplate({
1146
2641
  const isDark = theme === "dark";
1147
2642
  const cssVars = {
1148
2643
  "--pollar-accent": accentColor,
1149
- "--pollar-buttons-border-radius": "8px",
1150
- "--pollar-buttons-height": "44px",
1151
2644
  "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
1152
2645
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
1153
2646
  "--pollar-text": isDark ? "#ffffff" : "#111827",
1154
2647
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
1155
- "--pollar-input-bg": isDark ? "#374151" : "rgba(0,0,0,0.04)",
2648
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2649
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2650
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
1156
2651
  "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
1157
- "--pollar-success-text": isDark ? "#4ade80" : "#16a34a"
2652
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2653
+ "--pollar-buttons-border-radius": "6px",
2654
+ "--pollar-buttons-height": "44px",
2655
+ "--pollar-input-height": "44px",
2656
+ "--pollar-input-border-radius": "0.5rem",
2657
+ "--pollar-card-border-radius": "10px"
1158
2658
  };
1159
2659
  const isLoading = txHistory.step === "loading";
1160
2660
  const records = txHistory.step === "loaded" ? txHistory.data.records : [];
@@ -1162,7 +2662,7 @@ function TxHistoryModalTemplate({
1162
2662
  const hasPrev = offset > 0;
1163
2663
  const hasNext = offset + PAGE_SIZE < total;
1164
2664
  const showPagination = txHistory.step === "loaded" && total > PAGE_SIZE;
1165
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
2665
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-hist-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
1166
2666
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
1167
2667
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Transaction History" }),
1168
2668
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
@@ -1200,22 +2700,33 @@ function TxHistoryModalTemplate({
1200
2700
  isLoading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
1201
2701
  txHistory.step === "error" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: txHistory.message }),
1202
2702
  txHistory.step === "loaded" && records.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-modal-empty", children: "No transactions yet." }),
1203
- records.map((record) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-item", children: [
1204
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-summary", children: record.summary }),
1205
- /* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: record.status }),
1206
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-meta", children: [
1207
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: record.operation }),
1208
- record.feeXlm && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1209
- "\xB7 ",
1210
- record.feeXlm,
1211
- " XLM"
1212
- ] }),
1213
- /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1214
- "\xB7 ",
1215
- formatDate(record.createdAt)
2703
+ records.map((record) => {
2704
+ const explorerUrl = `https://stellar.expert/explorer/${record.network === "testnet" ? "testnet" : "public"}/tx/${record.hash}`;
2705
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-item", children: [
2706
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-hist-item-summary", children: record.summary }),
2707
+ /* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: record.status }),
2708
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-item-meta", children: [
2709
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: record.operation }),
2710
+ record.feeXlm && /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2711
+ "\xB7 ",
2712
+ record.feeXlm,
2713
+ " XLM"
2714
+ ] }),
2715
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2716
+ "\xB7 ",
2717
+ formatDate(record.createdAt)
2718
+ ] }),
2719
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xB7" }),
2720
+ /* @__PURE__ */ jsxRuntime.jsxs("a", { className: "pollar-hist-item-explorer", href: explorerUrl, target: "_blank", rel: "noopener noreferrer", "aria-label": "View on Stellar Explorer", children: [
2721
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "11", height: "11", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
2722
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 2H2a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
2723
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 1h4m0 0v4m0-4L6 7", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
2724
+ ] }),
2725
+ "Explorer"
2726
+ ] })
1216
2727
  ] })
1217
- ] })
1218
- ] }, record.id))
2728
+ ] }, record.id);
2729
+ })
1219
2730
  ] }),
1220
2731
  showPagination && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-hist-pagination", children: [
1221
2732
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-hist-pagination-info", children: [
@@ -1238,10 +2749,13 @@ function TxHistoryModal({ onClose }) {
1238
2749
  const { getClient, styles, txHistory } = usePollar();
1239
2750
  const { theme = "light", accentColor = "#005DB4" } = styles;
1240
2751
  const [offset, setOffset] = react.useState(0);
1241
- function load(nextOffset) {
2752
+ const load = react.useCallback((nextOffset) => {
1242
2753
  setOffset(nextOffset);
1243
2754
  void getClient().fetchTxHistory({ limit: PAGE_SIZE2, offset: nextOffset });
1244
- }
2755
+ }, [getClient]);
2756
+ react.useEffect(() => {
2757
+ load(0);
2758
+ }, [load]);
1245
2759
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
1246
2760
  TxHistoryModalTemplate,
1247
2761
  {
@@ -1256,7 +2770,7 @@ function TxHistoryModal({ onClose }) {
1256
2770
  }
1257
2771
  ) });
1258
2772
  }
1259
- function formatBalance(balance) {
2773
+ function formatBalance2(balance) {
1260
2774
  const n = parseFloat(balance);
1261
2775
  return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
1262
2776
  }
@@ -1269,9 +2783,9 @@ function BalanceItem({ record }) {
1269
2783
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-item", children: [
1270
2784
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pollar-bal-asset", children: record.code }),
1271
2785
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-amounts", children: [
1272
- /* @__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) }),
1273
2787
  balanceDiffers && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pollar-bal-available", children: [
1274
- formatBalance(record.available),
2788
+ formatBalance2(record.available),
1275
2789
  " available"
1276
2790
  ] })
1277
2791
  ] })
@@ -1292,12 +2806,20 @@ function WalletBalanceModalTemplate({
1292
2806
  "--pollar-border": isDark ? "#374151" : "#e5e7eb",
1293
2807
  "--pollar-text": isDark ? "#ffffff" : "#111827",
1294
2808
  "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
1295
- "--pollar-input-bg": isDark ? "#374151" : "rgba(0,0,0,0.04)",
1296
- "--pollar-error-text": isDark ? "#f87171" : "#dc2626"
2809
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2810
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2811
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
2812
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
2813
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2814
+ "--pollar-buttons-border-radius": "6px",
2815
+ "--pollar-buttons-height": "44px",
2816
+ "--pollar-input-height": "44px",
2817
+ "--pollar-input-border-radius": "0.5rem",
2818
+ "--pollar-card-border-radius": "10px"
1297
2819
  };
1298
2820
  const isLoading = walletBalance.step === "loading";
1299
2821
  const data = walletBalance.step === "loaded" ? walletBalance.data : null;
1300
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-bal-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
2822
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-card pollar-bal-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
1301
2823
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header", children: [
1302
2824
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "pollar-modal-title", children: "Wallet Balance" }),
1303
2825
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pollar-modal-header-actions", children: [
@@ -1336,11 +2858,11 @@ function WalletBalanceModalTemplate({
1336
2858
  ] });
1337
2859
  }
1338
2860
  function WalletBalanceModal({ onClose }) {
1339
- const { walletBalance, refreshBalance, walletAddress, styles } = usePollar();
2861
+ const { walletBalance, refreshWalletBalance, walletAddress, styles } = usePollar();
1340
2862
  const { theme = "light", accentColor = "#005DB4" } = styles;
1341
2863
  react.useEffect(() => {
1342
- void refreshBalance();
1343
- }, []);
2864
+ void refreshWalletBalance();
2865
+ }, [refreshWalletBalance]);
1344
2866
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(
1345
2867
  WalletBalanceModalTemplate,
1346
2868
  {
@@ -1348,7 +2870,7 @@ function WalletBalanceModal({ onClose }) {
1348
2870
  accentColor,
1349
2871
  walletBalance,
1350
2872
  walletAddress,
1351
- onRefresh: () => refreshBalance(),
2873
+ onRefresh: () => refreshWalletBalance(),
1352
2874
  onClose
1353
2875
  }
1354
2876
  ) });
@@ -1364,7 +2886,7 @@ async function fetchRemoteConfig(client) {
1364
2886
  return content ?? emptyResponse;
1365
2887
  }
1366
2888
  var PollarContext = react.createContext(null);
1367
- function PollarProvider({ config, styles: propStyles, children }) {
2889
+ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1368
2890
  const [pollarClient] = react.useState(() => new core.PollarClient(config));
1369
2891
  const [networkState, setNetworkState] = react.useState(() => pollarClient.getNetworkState());
1370
2892
  const [sessionState, setSessionState] = react.useState(null);
@@ -1373,6 +2895,8 @@ function PollarProvider({ config, styles: propStyles, children }) {
1373
2895
  const [walletBalance, setWalletBalance] = react.useState({ step: "idle" });
1374
2896
  const [remoteConfig, setRemoteConfig] = react.useState(emptyResponse);
1375
2897
  const [styles, setStyles] = react.useState(propStyles ?? {});
2898
+ const propStylesRef = react.useRef(propStyles);
2899
+ propStylesRef.current = propStyles;
1376
2900
  react.useEffect(() => {
1377
2901
  return pollarClient.onTransactionStateChange(setTransaction);
1378
2902
  }, [pollarClient]);
@@ -1397,58 +2921,75 @@ function PollarProvider({ config, styles: propStyles, children }) {
1397
2921
  });
1398
2922
  }, [pollarClient]);
1399
2923
  react.useEffect(() => {
2924
+ const propStyles2 = propStylesRef.current;
1400
2925
  fetchRemoteConfig(pollarClient).then((fetched) => {
1401
2926
  setRemoteConfig(fetched);
1402
2927
  setStyles({
1403
2928
  ...fetched.styles,
1404
- ...propStyles,
1405
- providers: { ...fetched.styles?.providers, ...propStyles?.providers }
2929
+ ...propStyles2,
2930
+ providers: { ...fetched.styles?.providers, ...propStyles2?.providers }
1406
2931
  });
1407
2932
  }).catch(() => {
1408
- setStyles(propStyles ?? {});
2933
+ setStyles(propStyles2 ?? {});
1409
2934
  });
1410
2935
  }, [pollarClient]);
1411
- react.useEffect(() => {
1412
- if (transaction.step !== "idle") {
1413
- setTransactionModalOpen(true);
1414
- }
1415
- }, [transaction.step]);
1416
2936
  const [loginModalOpen, setLoginModalOpen] = react.useState(false);
1417
2937
  const [transactionModalOpen, setTransactionModalOpen] = react.useState(false);
1418
2938
  const [kycModalOpen, setKycModalOpen] = react.useState(false);
1419
2939
  const [kycModalOptions, setKycModalOptions] = react.useState({});
1420
- const [rampWidgetOpen, setRampWidgetOpen] = react.useState(false);
2940
+ const [rampModalOpen, setRampModalOpen] = react.useState(false);
1421
2941
  const [txHistoryModalOpen, setTxHistoryModalOpen] = react.useState(false);
1422
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]);
1423
2950
  const contextValue = react.useMemo(
1424
2951
  () => ({
1425
- walletAddress: sessionState?.data?.providers?.wallet?.address || sessionState?.wallet?.publicKey || "",
1426
- getClient: () => pollarClient,
1427
- transaction,
2952
+ // session
2953
+ walletAddress,
2954
+ isAuthenticated: !!walletAddress,
2955
+ walletType: pollarClient.getWalletType(),
2956
+ // client
2957
+ getClient,
2958
+ // auth
1428
2959
  login: (options) => pollarClient.login(options),
1429
2960
  logout: () => pollarClient.logout(),
1430
- isAuthenticated: !!sessionState?.wallet?.publicKey,
2961
+ openLoginModal: () => setLoginModalOpen(true),
2962
+ // transactions
2963
+ tx: transaction,
1431
2964
  buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
1432
2965
  signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
1433
- walletType: pollarClient.getWalletType(),
1434
- openTransactionModal: () => setTransactionModalOpen(true),
1435
- openLoginModal: () => setLoginModalOpen(true),
1436
- openKycModal: (options = {}) => {
1437
- setKycModalOptions(options);
1438
- setKycModalOpen(true);
1439
- },
1440
- openRampWidget: () => setRampWidgetOpen(true),
2966
+ openTxModal: () => setTransactionModalOpen(true),
2967
+ // tx history
1441
2968
  txHistory,
1442
2969
  openTxHistoryModal: () => setTxHistoryModalOpen(true),
1443
- openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
2970
+ // wallet balance
1444
2971
  walletBalance,
1445
- refreshBalance: (publicKey) => pollarClient.refreshBalance(publicKey),
2972
+ refreshWalletBalance,
2973
+ openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
2974
+ // send / receive
2975
+ openSendModal: () => setSendModalOpen(true),
2976
+ openReceiveModal: () => setReceiveModalOpen(true),
2977
+ // network
1446
2978
  network: networkState.step === "connected" ? networkState.network : "testnet",
1447
2979
  setNetwork: (network) => pollarClient.setNetwork(network),
1448
- config: remoteConfig,
1449
- styles
2980
+ // kyc
2981
+ openKycModal: (options = {}) => {
2982
+ setKycModalOptions(options);
2983
+ setKycModalOpen(true);
2984
+ },
2985
+ // ramp
2986
+ openRampModal: () => setRampModalOpen(true),
2987
+ // config
2988
+ appConfig: remoteConfig,
2989
+ styles,
2990
+ adapters: adaptersRef.current
1450
2991
  }),
1451
- [sessionState, remoteConfig, styles, pollarClient, transaction, txHistory, networkState, walletBalance]
2992
+ [walletAddress, pollarClient, getClient, transaction, txHistory, walletBalance, refreshWalletBalance, networkState, remoteConfig, styles]
1452
2993
  );
1453
2994
  return /* @__PURE__ */ jsxRuntime.jsxs(PollarContext.Provider, { value: contextValue, children: [
1454
2995
  children,
@@ -1463,9 +3004,11 @@ function PollarProvider({ config, styles: propStyles, children }) {
1463
3004
  ...kycModalOptions.onApproved !== void 0 && { onApproved: kycModalOptions.onApproved }
1464
3005
  }
1465
3006
  ) }),
1466
- 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) }) }),
1467
3008
  txHistoryModalOpen && /* @__PURE__ */ jsxRuntime.jsx(ModalErrorBoundary, { onClose: () => setTxHistoryModalOpen(false), children: /* @__PURE__ */ jsxRuntime.jsx(TxHistoryModal, { onClose: () => setTxHistoryModalOpen(false) }) }),
1468
- 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) }) })
1469
3012
  ] });
1470
3013
  }
1471
3014
  function usePollar() {
@@ -1475,6 +3018,26 @@ function usePollar() {
1475
3018
  }
1476
3019
  return ctx;
1477
3020
  }
3021
+
3022
+ // src/usePollarAdapter.ts
3023
+ function createPollarAdapterHook(key) {
3024
+ return function usePollarAdapter() {
3025
+ const { adapters, signAndSubmitTx } = usePollar();
3026
+ const adapter = adapters?.[key];
3027
+ if (!adapter) {
3028
+ throw new Error(`No adapter "${key}" provided to PollarProvider`);
3029
+ }
3030
+ return Object.fromEntries(
3031
+ Object.entries(adapter).map(([name, fn]) => [
3032
+ name,
3033
+ async (params) => {
3034
+ const { unsignedTransaction } = await fn(params);
3035
+ await signAndSubmitTx(unsignedTransaction);
3036
+ }
3037
+ ])
3038
+ );
3039
+ };
3040
+ }
1478
3041
  function ButtonLogo() {
1479
3042
  return /* @__PURE__ */ jsxRuntime.jsx("img", { src: LOGO_POLLAR, alt: "Pollar", width: 22, height: 22, className: "wallet-btn-logo" });
1480
3043
  }
@@ -1491,10 +3054,13 @@ function WalletButtonTemplate({
1491
3054
  dropdownBorder,
1492
3055
  itemColor,
1493
3056
  wrapperRef,
3057
+ isInProgress,
1494
3058
  onToggleOpen,
1495
3059
  onCopy,
1496
3060
  onWalletBalance,
1497
3061
  onTxHistory,
3062
+ onSend,
3063
+ onReceive,
1498
3064
  onLogout,
1499
3065
  onLogin
1500
3066
  }) {
@@ -1505,132 +3071,129 @@ function WalletButtonTemplate({
1505
3071
  ] });
1506
3072
  }
1507
3073
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "wallet-wrapper", ref: wrapperRef, children: [
1508
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-btn", style: { backgroundColor: accentColor }, onClick: onToggleOpen, children: [
1509
- cropWallet(walletAddress),
1510
- /* @__PURE__ */ jsxRuntime.jsx(
1511
- "svg",
1512
- {
1513
- className: `wallet-chevron${open ? " open" : ""}`,
1514
- viewBox: "0 0 12 12",
1515
- fill: "none",
1516
- stroke: "currentColor",
1517
- strokeWidth: "2",
1518
- strokeLinecap: "round",
1519
- strokeLinejoin: "round",
1520
- children: /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "2,4 6,8 10,4" })
1521
- }
1522
- )
1523
- ] }),
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
+ ),
1524
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" }),
1525
3143
  /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
1526
- /* @__PURE__ */ jsxRuntime.jsxs(
1527
- "svg",
1528
- {
1529
- width: "14",
1530
- height: "14",
1531
- viewBox: "0 0 24 24",
1532
- fill: "none",
1533
- stroke: "currentColor",
1534
- strokeWidth: "2",
1535
- strokeLinecap: "round",
1536
- strokeLinejoin: "round",
1537
- children: [
1538
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
1539
- /* @__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" })
1540
- ]
1541
- }
1542
- ),
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
+ ] }),
1543
3148
  copied ? "Copied!" : "Copy address"
1544
3149
  ] }),
1545
- /* @__PURE__ */ jsxRuntime.jsxs(
1546
- "button",
1547
- {
1548
- className: "wallet-dropdown-item",
1549
- style: { color: itemColor },
1550
- onClick: onWalletBalance,
1551
- children: [
1552
- /* @__PURE__ */ jsxRuntime.jsxs(
1553
- "svg",
1554
- {
1555
- width: "14",
1556
- height: "14",
1557
- viewBox: "0 0 24 24",
1558
- fill: "none",
1559
- stroke: "currentColor",
1560
- strokeWidth: "2",
1561
- strokeLinecap: "round",
1562
- strokeLinejoin: "round",
1563
- children: [
1564
- /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "1", y: "4", width: "22", height: "16", rx: "2", ry: "2" }),
1565
- /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "16", cy: "12", r: "2" }),
1566
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M22 8H12" })
1567
- ]
1568
- }
1569
- ),
1570
- "Wallet balance"
1571
- ]
1572
- }
1573
- ),
1574
- /* @__PURE__ */ jsxRuntime.jsxs(
1575
- "button",
1576
- {
1577
- className: "wallet-dropdown-item",
1578
- style: { color: itemColor },
1579
- onClick: onTxHistory,
1580
- children: [
1581
- /* @__PURE__ */ jsxRuntime.jsxs(
1582
- "svg",
1583
- {
1584
- width: "14",
1585
- height: "14",
1586
- viewBox: "0 0 24 24",
1587
- fill: "none",
1588
- stroke: "currentColor",
1589
- strokeWidth: "2",
1590
- strokeLinecap: "round",
1591
- strokeLinejoin: "round",
1592
- children: [
1593
- /* @__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" }),
1594
- /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "14,2 14,8 20,8" }),
1595
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
1596
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
1597
- /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "10,9 9,9 8,9" })
1598
- ]
1599
- }
1600
- ),
1601
- "Transaction history"
1602
- ]
1603
- }
1604
- ),
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" }),
1605
3169
  /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
1606
- /* @__PURE__ */ jsxRuntime.jsxs(
1607
- "svg",
1608
- {
1609
- width: "14",
1610
- height: "14",
1611
- viewBox: "0 0 24 24",
1612
- fill: "none",
1613
- stroke: "currentColor",
1614
- strokeWidth: "2",
1615
- strokeLinecap: "round",
1616
- strokeLinejoin: "round",
1617
- children: [
1618
- /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
1619
- /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "16,17 21,12 16,7" }),
1620
- /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
1621
- ]
1622
- }
1623
- ),
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
+ ] }),
1624
3175
  "Log out"
1625
3176
  ] })
1626
3177
  ] })
1627
3178
  ] });
1628
3179
  }
1629
3180
  function WalletButton() {
1630
- 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();
1631
3193
  const [open, setOpen] = react.useState(false);
1632
3194
  const [copied, setCopied] = react.useState(false);
1633
3195
  const wrapperRef = react.useRef(null);
3196
+ const isInProgress = transaction.step === "building" || transaction.step === "signing";
1634
3197
  const { theme = "light", accentColor = "#005DB4" } = styles;
1635
3198
  const isDark = theme === "dark";
1636
3199
  const dropdownBg = isDark ? "#18181b" : "#fff";
@@ -1663,6 +3226,14 @@ function WalletButton() {
1663
3226
  setOpen(false);
1664
3227
  openTxHistoryModal();
1665
3228
  }
3229
+ function handleSend() {
3230
+ setOpen(false);
3231
+ openSendModal();
3232
+ }
3233
+ function handleReceive() {
3234
+ setOpen(false);
3235
+ openReceiveModal();
3236
+ }
1666
3237
  return /* @__PURE__ */ jsxRuntime.jsx(
1667
3238
  WalletButtonTemplate,
1668
3239
  {
@@ -1674,10 +3245,14 @@ function WalletButton() {
1674
3245
  dropdownBorder,
1675
3246
  itemColor,
1676
3247
  wrapperRef,
3248
+ isInProgress,
3249
+ walletType,
1677
3250
  onToggleOpen: () => setOpen((v) => !v),
1678
3251
  onCopy: handleCopy,
1679
3252
  onWalletBalance: handleWalletBalance,
1680
3253
  onTxHistory: handleTxHistory,
3254
+ onSend: handleSend,
3255
+ onReceive: handleReceive,
1681
3256
  onLogout: handleLogout,
1682
3257
  onLogin: openLoginModal
1683
3258
  }
@@ -1691,12 +3266,18 @@ exports.LoginModalTemplate = LoginModalTemplate;
1691
3266
  exports.PollarProvider = PollarProvider;
1692
3267
  exports.RampWidget = RampWidget;
1693
3268
  exports.RampWidgetTemplate = RampWidgetTemplate;
3269
+ exports.ReceiveModal = ReceiveModal;
3270
+ exports.ReceiveModalTemplate = ReceiveModalTemplate;
1694
3271
  exports.RouteDisplay = RouteDisplay;
3272
+ exports.SendModal = SendModal;
3273
+ exports.SendModalTemplate = SendModalTemplate;
1695
3274
  exports.TransactionModalTemplate = TransactionModalTemplate;
1696
3275
  exports.TxHistoryModalTemplate = TxHistoryModalTemplate;
3276
+ exports.TxStatusView = TxStatusView;
1697
3277
  exports.WalletBalanceModal = WalletBalanceModal;
1698
3278
  exports.WalletBalanceModalTemplate = WalletBalanceModalTemplate;
1699
3279
  exports.WalletButton = WalletButton;
3280
+ exports.createPollarAdapterHook = createPollarAdapterHook;
1700
3281
  exports.usePollar = usePollar;
1701
3282
  //# sourceMappingURL=index.js.map
1702
3283
  //# sourceMappingURL=index.js.map