coinley-checkout 0.3.1 → 0.3.2
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.
@@ -1,33 +1,33 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var
|
4
|
-
var
|
5
|
-
var
|
6
|
-
for (var
|
7
|
-
|
8
|
-
if (
|
9
|
-
for (var
|
10
|
-
|
1
|
+
var qe = Object.defineProperty, He = Object.defineProperties;
|
2
|
+
var $e = Object.getOwnPropertyDescriptors;
|
3
|
+
var ge = Object.getOwnPropertySymbols;
|
4
|
+
var Ke = Object.prototype.hasOwnProperty, Ve = Object.prototype.propertyIsEnumerable;
|
5
|
+
var fe = (s, t, e) => t in s ? qe(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, z = (s, t) => {
|
6
|
+
for (var e in t || (t = {}))
|
7
|
+
Ke.call(t, e) && fe(s, e, t[e]);
|
8
|
+
if (ge)
|
9
|
+
for (var e of ge(t))
|
10
|
+
Ve.call(t, e) && fe(s, e, t[e]);
|
11
11
|
return s;
|
12
|
-
}, we = (s,
|
13
|
-
var R = (s,
|
14
|
-
var
|
12
|
+
}, we = (s, t) => He(s, $e(t));
|
13
|
+
var R = (s, t, e) => new Promise((i, c) => {
|
14
|
+
var u = (r) => {
|
15
15
|
try {
|
16
|
-
|
16
|
+
x(e.next(r));
|
17
17
|
} catch (n) {
|
18
|
-
|
18
|
+
c(n);
|
19
19
|
}
|
20
|
-
}, y = (
|
20
|
+
}, y = (r) => {
|
21
21
|
try {
|
22
|
-
|
22
|
+
x(e.throw(r));
|
23
23
|
} catch (n) {
|
24
|
-
|
24
|
+
c(n);
|
25
25
|
}
|
26
|
-
},
|
27
|
-
|
26
|
+
}, x = (r) => r.done ? i(r.value) : Promise.resolve(r.value).then(u, y);
|
27
|
+
x((e = e.apply(s, t)).next());
|
28
28
|
});
|
29
|
-
import
|
30
|
-
const
|
29
|
+
import L, { createContext as xe, useContext as ye, useState as D, useEffect as Z, forwardRef as _e, useImperativeHandle as Je } from "react";
|
30
|
+
const b = {
|
31
31
|
ETHEREUM: "ethereum",
|
32
32
|
BSC: "bsc",
|
33
33
|
TRON: "tron",
|
@@ -38,7 +38,7 @@ const A = {
|
|
38
38
|
TRUST_WALLET: "trust_wallet",
|
39
39
|
LUTE: "lute"
|
40
40
|
}, de = {
|
41
|
-
[
|
41
|
+
[b.ETHEREUM]: {
|
42
42
|
chainId: "0x1",
|
43
43
|
chainName: "Ethereum Mainnet",
|
44
44
|
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
@@ -46,7 +46,7 @@ const A = {
|
|
46
46
|
blockExplorerUrls: ["https://etherscan.io/"],
|
47
47
|
supportedWallets: [N.METAMASK, N.TRUST_WALLET]
|
48
48
|
},
|
49
|
-
[
|
49
|
+
[b.BSC]: {
|
50
50
|
chainId: "0x38",
|
51
51
|
chainName: "BNB Smart Chain",
|
52
52
|
nativeCurrency: { name: "BNB", symbol: "BNB", decimals: 18 },
|
@@ -54,54 +54,54 @@ const A = {
|
|
54
54
|
blockExplorerUrls: ["https://bscscan.com/"],
|
55
55
|
supportedWallets: [N.METAMASK, N.TRUST_WALLET]
|
56
56
|
},
|
57
|
-
[
|
57
|
+
[b.TRON]: {
|
58
58
|
fullHost: "https://api.trongrid.io",
|
59
59
|
explorerUrl: "https://tronscan.org",
|
60
60
|
supportedWallets: [N.TRONLINK]
|
61
61
|
},
|
62
|
-
[
|
62
|
+
[b.ALGORAND]: {
|
63
63
|
network: "mainnet",
|
64
64
|
explorerUrl: "https://algoexplorer.io",
|
65
65
|
supportedWallets: [N.LUTE]
|
66
66
|
}
|
67
|
-
},
|
67
|
+
}, Ye = {
|
68
68
|
USDT: {
|
69
|
-
[
|
69
|
+
[b.ETHEREUM]: {
|
70
70
|
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
71
71
|
decimals: 6
|
72
72
|
},
|
73
|
-
[
|
73
|
+
[b.BSC]: {
|
74
74
|
address: "0x55d398326f99059fF775485246999027B3197955",
|
75
75
|
decimals: 18
|
76
76
|
},
|
77
|
-
[
|
77
|
+
[b.TRON]: {
|
78
78
|
address: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
79
79
|
decimals: 6
|
80
80
|
}
|
81
81
|
},
|
82
82
|
USDC: {
|
83
|
-
[
|
83
|
+
[b.ETHEREUM]: {
|
84
84
|
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
85
85
|
decimals: 6
|
86
86
|
},
|
87
|
-
[
|
87
|
+
[b.BSC]: {
|
88
88
|
address: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
|
89
89
|
decimals: 18
|
90
90
|
},
|
91
|
-
[
|
91
|
+
[b.TRON]: {
|
92
92
|
address: "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",
|
93
93
|
decimals: 6
|
94
94
|
}
|
95
95
|
},
|
96
96
|
ALGO: {
|
97
|
-
[
|
97
|
+
[b.ALGORAND]: {
|
98
98
|
address: "native",
|
99
99
|
decimals: 6
|
100
100
|
}
|
101
101
|
}
|
102
102
|
};
|
103
103
|
let _ = null;
|
104
|
-
const
|
104
|
+
const Xe = () => R(void 0, null, function* () {
|
105
105
|
if (_)
|
106
106
|
return _;
|
107
107
|
try {
|
@@ -123,24 +123,24 @@ const Ze = () => R(void 0, null, function* () {
|
|
123
123
|
return s;
|
124
124
|
try {
|
125
125
|
s[N.METAMASK] = !!(window.ethereum && window.ethereum.isMetaMask), s[N.TRONLINK] = !!window.tronWeb, s[N.TRUST_WALLET] = !!(window.ethereum && window.ethereum.isTrust), s[N.LUTE] = !!(window.algorand && window.algorand.isLute);
|
126
|
-
} catch (
|
127
|
-
console.warn("Error detecting wallets:",
|
126
|
+
} catch (t) {
|
127
|
+
console.warn("Error detecting wallets:", t);
|
128
128
|
}
|
129
129
|
return s;
|
130
|
-
},
|
131
|
-
const
|
132
|
-
if (!
|
130
|
+
}, Ze = (s) => {
|
131
|
+
const t = de[s];
|
132
|
+
if (!t)
|
133
133
|
return [];
|
134
|
-
const
|
135
|
-
return
|
136
|
-
}, et = (s,
|
134
|
+
const e = ue();
|
135
|
+
return t.supportedWallets.filter((i) => e[i]);
|
136
|
+
}, et = (s, t) => R(void 0, null, function* () {
|
137
137
|
switch (s) {
|
138
138
|
case N.METAMASK:
|
139
|
-
return yield tt(
|
139
|
+
return yield tt(t);
|
140
140
|
case N.TRONLINK:
|
141
141
|
return yield rt();
|
142
142
|
case N.TRUST_WALLET:
|
143
|
-
return yield st(
|
143
|
+
return yield st(t);
|
144
144
|
case N.LUTE:
|
145
145
|
return yield nt();
|
146
146
|
default:
|
@@ -150,55 +150,55 @@ const Ze = () => R(void 0, null, function* () {
|
|
150
150
|
if (typeof window == "undefined" || !window.ethereum || !window.ethereum.isMetaMask)
|
151
151
|
throw new Error("MetaMask is not installed. Please install MetaMask extension.");
|
152
152
|
try {
|
153
|
-
const
|
153
|
+
const t = yield window.ethereum.request({
|
154
154
|
method: "eth_requestAccounts"
|
155
155
|
});
|
156
|
-
if (!
|
156
|
+
if (!t || t.length === 0)
|
157
157
|
throw new Error("No accounts found. Please unlock MetaMask.");
|
158
|
-
const
|
159
|
-
return
|
160
|
-
address:
|
158
|
+
const e = de[s];
|
159
|
+
return e && e.chainId && (yield be(e)), {
|
160
|
+
address: t[0],
|
161
161
|
network: s,
|
162
162
|
walletType: N.METAMASK
|
163
163
|
};
|
164
|
-
} catch (
|
165
|
-
throw
|
164
|
+
} catch (t) {
|
165
|
+
throw t.code === 4001 ? new Error("User rejected the connection request") : new Error(`Failed to connect MetaMask: ${t.message}`);
|
166
166
|
}
|
167
167
|
}), rt = () => R(void 0, null, function* () {
|
168
|
-
var
|
168
|
+
var i;
|
169
169
|
if (typeof window == "undefined" || !window.tronWeb)
|
170
170
|
throw new Error("TronLink is not installed. Please install TronLink extension.");
|
171
171
|
let s = 0;
|
172
|
-
const
|
173
|
-
for (; !window.tronWeb.ready && s <
|
174
|
-
yield new Promise((
|
172
|
+
const t = 10;
|
173
|
+
for (; !window.tronWeb.ready && s < t; )
|
174
|
+
yield new Promise((c) => setTimeout(c, 1e3)), s++;
|
175
175
|
if (!window.tronWeb.ready)
|
176
176
|
throw new Error("TronLink is not ready. Please unlock your TronLink wallet and try again.");
|
177
|
-
const
|
178
|
-
if (!
|
177
|
+
const e = (i = window.tronWeb.defaultAddress) == null ? void 0 : i.base58;
|
178
|
+
if (!e)
|
179
179
|
throw new Error("No account found in TronLink. Please make sure you have an account set up.");
|
180
180
|
return {
|
181
|
-
address:
|
182
|
-
network:
|
181
|
+
address: e,
|
182
|
+
network: b.TRON,
|
183
183
|
walletType: N.TRONLINK
|
184
184
|
};
|
185
185
|
}), st = (s) => R(void 0, null, function* () {
|
186
186
|
if (typeof window == "undefined" || !window.ethereum || !window.ethereum.isTrust)
|
187
187
|
throw new Error("Trust Wallet is not installed. Please install Trust Wallet extension.");
|
188
188
|
try {
|
189
|
-
const
|
189
|
+
const t = yield window.ethereum.request({
|
190
190
|
method: "eth_requestAccounts"
|
191
191
|
});
|
192
|
-
if (!
|
192
|
+
if (!t || t.length === 0)
|
193
193
|
throw new Error("No accounts found. Please unlock Trust Wallet.");
|
194
|
-
const
|
195
|
-
return
|
196
|
-
address:
|
194
|
+
const e = de[s];
|
195
|
+
return e && e.chainId && (yield be(e)), {
|
196
|
+
address: t[0],
|
197
197
|
network: s,
|
198
198
|
walletType: N.TRUST_WALLET
|
199
199
|
};
|
200
|
-
} catch (
|
201
|
-
throw
|
200
|
+
} catch (t) {
|
201
|
+
throw t.code === 4001 ? new Error("User rejected the connection request") : new Error(`Failed to connect Trust Wallet: ${t.message}`);
|
202
202
|
}
|
203
203
|
}), nt = () => R(void 0, null, function* () {
|
204
204
|
if (typeof window == "undefined" || !window.algorand || !window.algorand.isLute)
|
@@ -209,13 +209,13 @@ const Ze = () => R(void 0, null, function* () {
|
|
209
209
|
throw new Error("No accounts found. Please unlock Lute wallet.");
|
210
210
|
return {
|
211
211
|
address: s[0],
|
212
|
-
network:
|
212
|
+
network: b.ALGORAND,
|
213
213
|
walletType: N.LUTE
|
214
214
|
};
|
215
215
|
} catch (s) {
|
216
216
|
throw new Error(`Failed to connect Lute wallet: ${s.message}`);
|
217
217
|
}
|
218
|
-
}),
|
218
|
+
}), be = (s) => R(void 0, null, function* () {
|
219
219
|
if (typeof window == "undefined" || !window.ethereum)
|
220
220
|
throw new Error("Ethereum provider not found");
|
221
221
|
try {
|
@@ -223,41 +223,41 @@ const Ze = () => R(void 0, null, function* () {
|
|
223
223
|
method: "wallet_switchEthereumChain",
|
224
224
|
params: [{ chainId: s.chainId }]
|
225
225
|
});
|
226
|
-
} catch (
|
227
|
-
if (
|
226
|
+
} catch (t) {
|
227
|
+
if (t.code === 4902)
|
228
228
|
try {
|
229
229
|
yield window.ethereum.request({
|
230
230
|
method: "wallet_addEthereumChain",
|
231
231
|
params: [s]
|
232
232
|
});
|
233
|
-
} catch (
|
234
|
-
throw new Error(`Failed to add ${s.chainName} to wallet: ${
|
233
|
+
} catch (e) {
|
234
|
+
throw new Error(`Failed to add ${s.chainName} to wallet: ${e.message}`);
|
235
235
|
}
|
236
236
|
else
|
237
|
-
throw
|
237
|
+
throw t.code === 4001 ? new Error("User rejected network switch request") : new Error(`Failed to switch to ${s.chainName}: ${t.message}`);
|
238
238
|
}
|
239
|
-
}), ot = (s,
|
240
|
-
const { walletType:
|
241
|
-
switch (
|
239
|
+
}), ot = (s, t) => R(void 0, null, function* () {
|
240
|
+
const { walletType: e, network: i, address: c } = s, { to: u, amount: y, tokenAddress: x, tokenDecimals: r } = t;
|
241
|
+
switch (e) {
|
242
242
|
case N.METAMASK:
|
243
243
|
case N.TRUST_WALLET:
|
244
|
-
return yield at(
|
244
|
+
return yield at(c, u, y, x, r);
|
245
245
|
case N.TRONLINK:
|
246
|
-
return yield
|
246
|
+
return yield it(u, y, x, r);
|
247
247
|
case N.LUTE:
|
248
|
-
return yield
|
248
|
+
return yield lt(c, u, y);
|
249
249
|
default:
|
250
|
-
throw new Error(`Unsupported wallet type: ${
|
250
|
+
throw new Error(`Unsupported wallet type: ${e}`);
|
251
251
|
}
|
252
|
-
}), at = (s,
|
252
|
+
}), at = (s, t, e, i, c) => R(void 0, null, function* () {
|
253
253
|
if (typeof window == "undefined" || !window.ethereum)
|
254
254
|
throw new Error("Ethereum provider not found");
|
255
255
|
try {
|
256
|
-
const
|
257
|
-
Math.floor(parseFloat(
|
256
|
+
const u = yield Xe(), y = new u(window.ethereum), x = y.utils.toBN(
|
257
|
+
Math.floor(parseFloat(e) * Math.pow(10, c || 18))
|
258
258
|
);
|
259
|
-
if (
|
260
|
-
const
|
259
|
+
if (i && i !== "native") {
|
260
|
+
const r = [
|
261
261
|
{
|
262
262
|
constant: !1,
|
263
263
|
inputs: [
|
@@ -271,41 +271,41 @@ const Ze = () => R(void 0, null, function* () {
|
|
271
271
|
type: "function"
|
272
272
|
}
|
273
273
|
];
|
274
|
-
return (yield new y.eth.Contract(
|
274
|
+
return (yield new y.eth.Contract(r, i).methods.transfer(t, x).send({ from: s })).transactionHash;
|
275
275
|
} else
|
276
276
|
return (yield y.eth.sendTransaction({
|
277
277
|
from: s,
|
278
|
-
to:
|
279
|
-
value:
|
278
|
+
to: t,
|
279
|
+
value: x
|
280
280
|
})).transactionHash;
|
281
|
-
} catch (
|
282
|
-
throw
|
281
|
+
} catch (u) {
|
282
|
+
throw u.code === 4001 ? new Error("Transaction was rejected by user") : new Error(`Transaction failed: ${u.message}`);
|
283
283
|
}
|
284
|
-
}),
|
284
|
+
}), it = (s, t, e, i) => R(void 0, null, function* () {
|
285
285
|
if (typeof window == "undefined" || !window.tronWeb || !window.tronWeb.ready)
|
286
286
|
throw new Error("TronLink is not ready");
|
287
287
|
try {
|
288
|
-
const
|
289
|
-
return
|
288
|
+
const c = Math.floor(parseFloat(t) * Math.pow(10, i || 6));
|
289
|
+
return e && e !== "native" ? yield (yield window.tronWeb.contract().at(e)).transfer(s, c).send({
|
290
290
|
feeLimit: 1e8,
|
291
291
|
callValue: 0
|
292
|
-
}) : (yield window.tronWeb.trx.sendTransaction(s,
|
293
|
-
} catch (
|
294
|
-
throw new Error(`TRON transaction failed: ${
|
292
|
+
}) : (yield window.tronWeb.trx.sendTransaction(s, c)).txid;
|
293
|
+
} catch (c) {
|
294
|
+
throw new Error(`TRON transaction failed: ${c.message}`);
|
295
295
|
}
|
296
|
-
}),
|
296
|
+
}), lt = (s, t, e) => R(void 0, null, function* () {
|
297
297
|
if (typeof window == "undefined" || !window.algorand)
|
298
298
|
throw new Error("Algorand wallet is not available");
|
299
299
|
try {
|
300
|
-
const
|
300
|
+
const i = Math.floor(parseFloat(e) * 1e6), c = {
|
301
301
|
from: s,
|
302
|
-
to:
|
303
|
-
amount:
|
302
|
+
to: t,
|
303
|
+
amount: i,
|
304
304
|
type: "pay"
|
305
|
-
},
|
306
|
-
return (yield window.algorand.sendTransaction(
|
307
|
-
} catch (
|
308
|
-
throw new Error(`Algorand transaction failed: ${
|
305
|
+
}, u = yield window.algorand.signTransaction(c);
|
306
|
+
return (yield window.algorand.sendTransaction(u)).txId;
|
307
|
+
} catch (i) {
|
308
|
+
throw new Error(`Algorand transaction failed: ${i.message}`);
|
309
309
|
}
|
310
310
|
}), ct = (s) => ({
|
311
311
|
[N.METAMASK]: "https://metamask.io/",
|
@@ -313,7 +313,7 @@ const Ze = () => R(void 0, null, function* () {
|
|
313
313
|
[N.TRUST_WALLET]: "https://trustwallet.com/",
|
314
314
|
[N.LUTE]: "https://lute.app/"
|
315
315
|
})[s] || "";
|
316
|
-
let
|
316
|
+
let U = {
|
317
317
|
apiKey: null,
|
318
318
|
apiSecret: null,
|
319
319
|
apiUrl: "http://localhost:9000",
|
@@ -321,121 +321,121 @@ let P = {
|
|
321
321
|
// Changed to object for multi-network support
|
322
322
|
};
|
323
323
|
const dt = (s) => {
|
324
|
-
|
325
|
-
apiUrl:
|
326
|
-
apiKey:
|
327
|
-
hasWalletAddresses: Object.keys(
|
324
|
+
U = z(z({}, U), s), console.log("API initialized with:", {
|
325
|
+
apiUrl: U.apiUrl,
|
326
|
+
apiKey: U.apiKey ? `${U.apiKey.substring(0, 6)}...` : null,
|
327
|
+
hasWalletAddresses: Object.keys(U.merchantWalletAddresses || {}).length > 0
|
328
328
|
});
|
329
|
-
},
|
329
|
+
}, Y = () => ({
|
330
330
|
"Content-Type": "application/json",
|
331
|
-
"x-api-key":
|
332
|
-
"x-api-secret":
|
331
|
+
"x-api-key": U.apiKey,
|
332
|
+
"x-api-secret": U.apiSecret
|
333
333
|
}), ut = (s) => R(void 0, null, function* () {
|
334
334
|
try {
|
335
|
-
console.log("Creating payment with data:", s), console.log("API URL:", `${
|
336
|
-
const
|
337
|
-
merchantWalletAddresses: z(z({},
|
338
|
-
}),
|
335
|
+
console.log("Creating payment with data:", s), console.log("API URL:", `${U.apiUrl}/api/payments/create`);
|
336
|
+
const t = we(z({}, s), {
|
337
|
+
merchantWalletAddresses: z(z({}, U.merchantWalletAddresses), s.merchantWalletAddresses)
|
338
|
+
}), e = yield fetch(`${U.apiUrl}/api/payments/create`, {
|
339
339
|
method: "POST",
|
340
|
-
headers:
|
341
|
-
body: JSON.stringify(
|
340
|
+
headers: Y(),
|
341
|
+
body: JSON.stringify(t)
|
342
342
|
});
|
343
|
-
if (console.log("Create payment response status:",
|
344
|
-
const
|
345
|
-
throw console.error("Error creating payment:",
|
346
|
-
}
|
347
|
-
const
|
348
|
-
return console.log("Create payment response data:",
|
349
|
-
} catch (
|
350
|
-
throw console.error("Create payment error:",
|
343
|
+
if (console.log("Create payment response status:", e.status), !e.ok) {
|
344
|
+
const c = yield e.json();
|
345
|
+
throw console.error("Error creating payment:", c), new Error(c.error || `Failed to create payment: ${e.status}`);
|
346
|
+
}
|
347
|
+
const i = yield e.json();
|
348
|
+
return console.log("Create payment response data:", i), i;
|
349
|
+
} catch (t) {
|
350
|
+
throw console.error("Create payment error:", t), t;
|
351
351
|
}
|
352
|
-
}),
|
352
|
+
}), Bt = (s) => R(void 0, null, function* () {
|
353
353
|
try {
|
354
354
|
console.log("Getting payment:", s);
|
355
|
-
const
|
355
|
+
const t = yield fetch(`${U.apiUrl}/api/payments/${s}`, {
|
356
356
|
method: "GET",
|
357
|
-
headers:
|
357
|
+
headers: Y()
|
358
358
|
});
|
359
|
-
if (!
|
360
|
-
const
|
361
|
-
throw console.error("Error getting payment:",
|
362
|
-
}
|
363
|
-
const
|
364
|
-
return console.log("Get payment response:",
|
365
|
-
} catch (
|
366
|
-
throw console.error("Get payment error:",
|
359
|
+
if (!t.ok) {
|
360
|
+
const i = yield t.json();
|
361
|
+
throw console.error("Error getting payment:", i), new Error(i.error || `Failed to get payment: ${t.status}`);
|
362
|
+
}
|
363
|
+
const e = yield t.json();
|
364
|
+
return console.log("Get payment response:", e), e;
|
365
|
+
} catch (t) {
|
366
|
+
throw console.error("Get payment error:", t), t;
|
367
367
|
}
|
368
368
|
}), ht = (s) => R(void 0, null, function* () {
|
369
369
|
try {
|
370
|
-
console.log("Processing payment with data:", s), console.log("API URL:", `${
|
371
|
-
const
|
370
|
+
console.log("Processing payment with data:", s), console.log("API URL:", `${U.apiUrl}/api/payments/process`);
|
371
|
+
const t = yield fetch(`${U.apiUrl}/api/payments/process`, {
|
372
372
|
method: "POST",
|
373
|
-
headers:
|
373
|
+
headers: Y(),
|
374
374
|
body: JSON.stringify(s)
|
375
375
|
});
|
376
|
-
if (console.log("Process payment response status:",
|
377
|
-
const
|
378
|
-
throw console.error("Error processing payment:",
|
379
|
-
}
|
380
|
-
const
|
381
|
-
return console.log("Process payment response data:",
|
382
|
-
} catch (
|
383
|
-
throw console.error("Process payment error:",
|
376
|
+
if (console.log("Process payment response status:", t.status), !t.ok) {
|
377
|
+
const i = yield t.json();
|
378
|
+
throw console.error("Error processing payment:", i), new Error(i.error || `Failed to process payment: ${t.status}`);
|
379
|
+
}
|
380
|
+
const e = yield t.json();
|
381
|
+
return console.log("Process payment response data:", e), e;
|
382
|
+
} catch (t) {
|
383
|
+
throw console.error("Process payment error:", t), t;
|
384
384
|
}
|
385
|
-
}),
|
385
|
+
}), Wt = () => R(void 0, null, function* () {
|
386
386
|
try {
|
387
|
-
const s = yield fetch(`${
|
387
|
+
const s = yield fetch(`${U.apiUrl}/api/networks`, {
|
388
388
|
method: "GET",
|
389
|
-
headers:
|
389
|
+
headers: Y()
|
390
390
|
});
|
391
391
|
if (!s.ok) {
|
392
|
-
const
|
393
|
-
throw new Error(
|
392
|
+
const e = yield s.json();
|
393
|
+
throw new Error(e.error || `Failed to get networks: ${s.status}`);
|
394
394
|
}
|
395
395
|
return yield s.json();
|
396
396
|
} catch (s) {
|
397
397
|
throw console.error("Get supported networks error:", s), s;
|
398
398
|
}
|
399
|
-
}),
|
399
|
+
}), Qt = () => R(void 0, null, function* () {
|
400
400
|
try {
|
401
|
-
const s = yield fetch(`${
|
401
|
+
const s = yield fetch(`${U.apiUrl}/api/merchants/profile`, {
|
402
402
|
method: "GET",
|
403
|
-
headers:
|
403
|
+
headers: Y()
|
404
404
|
});
|
405
405
|
if (!s.ok) {
|
406
|
-
const
|
407
|
-
throw new Error(
|
406
|
+
const e = yield s.json();
|
407
|
+
throw new Error(e.error || `Failed to get merchant profile: ${s.status}`);
|
408
408
|
}
|
409
|
-
const
|
410
|
-
return
|
409
|
+
const t = yield s.json();
|
410
|
+
return t.merchant && t.merchant.walletAddresses && (U.merchantWalletAddresses = z(z({}, U.merchantWalletAddresses), t.merchant.walletAddresses)), t;
|
411
411
|
} catch (s) {
|
412
412
|
throw console.error("Get merchant profile error:", s), s;
|
413
413
|
}
|
414
|
-
}),
|
414
|
+
}), zt = (s, t) => R(void 0, null, function* () {
|
415
415
|
try {
|
416
|
-
const
|
416
|
+
const e = yield fetch(`${U.apiUrl}/api/wallets/validate`, {
|
417
417
|
method: "POST",
|
418
|
-
headers:
|
419
|
-
body: JSON.stringify({ address: s, network:
|
418
|
+
headers: Y(),
|
419
|
+
body: JSON.stringify({ address: s, network: t })
|
420
420
|
});
|
421
|
-
if (!
|
422
|
-
const
|
423
|
-
throw new Error(
|
421
|
+
if (!e.ok) {
|
422
|
+
const c = yield e.json();
|
423
|
+
throw new Error(c.error || `Failed to validate address: ${e.status}`);
|
424
424
|
}
|
425
|
-
return yield
|
426
|
-
} catch (
|
427
|
-
throw console.error("Validate wallet address error:",
|
425
|
+
return yield e.json();
|
426
|
+
} catch (e) {
|
427
|
+
throw console.error("Validate wallet address error:", e), e;
|
428
428
|
}
|
429
|
-
}),
|
430
|
-
const
|
429
|
+
}), Gt = (s = "ethereum") => {
|
430
|
+
const e = {
|
431
431
|
ethereum: "0x",
|
432
432
|
bsc: "0x",
|
433
433
|
tron: "",
|
434
434
|
algorand: ""
|
435
|
-
}[s] || "0x",
|
436
|
-
return `${
|
435
|
+
}[s] || "0x", i = Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
436
|
+
return `${e}${i}`;
|
437
437
|
};
|
438
|
-
var
|
438
|
+
var Ne = { exports: {} }, ne = {};
|
439
439
|
/**
|
440
440
|
* @license React
|
441
441
|
* react-jsx-runtime.production.min.js
|
@@ -445,93 +445,93 @@ var be = { exports: {} }, ne = {};
|
|
445
445
|
* This source code is licensed under the MIT license found in the
|
446
446
|
* LICENSE file in the root directory of this source tree.
|
447
447
|
*/
|
448
|
-
var mt =
|
449
|
-
function
|
450
|
-
var
|
451
|
-
|
452
|
-
for (
|
453
|
-
wt.call(
|
448
|
+
var mt = L, gt = Symbol.for("react.element"), ft = Symbol.for("react.fragment"), wt = Object.prototype.hasOwnProperty, pt = mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, xt = { key: !0, ref: !0, __self: !0, __source: !0 };
|
449
|
+
function Ee(s, t, e) {
|
450
|
+
var i, c = {}, u = null, y = null;
|
451
|
+
e !== void 0 && (u = "" + e), t.key !== void 0 && (u = "" + t.key), t.ref !== void 0 && (y = t.ref);
|
452
|
+
for (i in t)
|
453
|
+
wt.call(t, i) && !xt.hasOwnProperty(i) && (c[i] = t[i]);
|
454
454
|
if (s && s.defaultProps)
|
455
|
-
for (
|
456
|
-
|
457
|
-
return { $$typeof:
|
455
|
+
for (i in t = s.defaultProps, t)
|
456
|
+
c[i] === void 0 && (c[i] = t[i]);
|
457
|
+
return { $$typeof: gt, type: s, key: u, ref: y, props: c, _owner: pt.current };
|
458
458
|
}
|
459
|
-
ne.Fragment =
|
460
|
-
ne.jsx =
|
461
|
-
ne.jsxs =
|
462
|
-
|
463
|
-
var
|
464
|
-
const ve =
|
465
|
-
const [
|
466
|
-
|
459
|
+
ne.Fragment = ft;
|
460
|
+
ne.jsx = Ee;
|
461
|
+
ne.jsxs = Ee;
|
462
|
+
Ne.exports = ne;
|
463
|
+
var o = Ne.exports;
|
464
|
+
const ve = xe(), yt = () => ye(ve), qt = ({ initialTheme: s = "light", children: t }) => {
|
465
|
+
const [e, i] = D(s), c = () => {
|
466
|
+
i((u) => u === "light" ? "dark" : "light");
|
467
467
|
};
|
468
468
|
return Z(() => {
|
469
|
-
document.documentElement.classList.remove("light", "dark"), document.documentElement.classList.add(
|
470
|
-
}, [
|
471
|
-
},
|
469
|
+
document.documentElement.classList.remove("light", "dark"), document.documentElement.classList.add(e);
|
470
|
+
}, [e]), /* @__PURE__ */ o.jsx(ve.Provider, { value: { theme: e, setTheme: i, toggleTheme: c }, children: t });
|
471
|
+
}, ke = xe(), bt = () => ye(ke), Ht = ({
|
472
472
|
apiKey: s,
|
473
|
-
apiSecret:
|
474
|
-
apiUrl:
|
475
|
-
merchantWalletAddress:
|
473
|
+
apiSecret: t,
|
474
|
+
apiUrl: e = "http://localhost:9000",
|
475
|
+
merchantWalletAddress: i = null,
|
476
476
|
// New prop for merchant wallet address
|
477
|
-
merchantSolWalletAddress:
|
477
|
+
merchantSolWalletAddress: c = null,
|
478
478
|
// New prop for Solana wallet address
|
479
|
-
debug:
|
479
|
+
debug: u = !1,
|
480
480
|
children: y
|
481
481
|
}) => {
|
482
|
-
const [
|
482
|
+
const [x, r] = D(!1), [n, a] = D(null), [l, d] = D(null);
|
483
483
|
Z(() => {
|
484
|
-
if (!s || !
|
485
|
-
|
484
|
+
if (!s || !t) {
|
485
|
+
a("API key and secret are required");
|
486
486
|
return;
|
487
487
|
}
|
488
488
|
try {
|
489
489
|
dt({
|
490
490
|
apiKey: s,
|
491
|
-
apiSecret:
|
492
|
-
apiUrl:
|
493
|
-
merchantWalletAddress:
|
491
|
+
apiSecret: t,
|
492
|
+
apiUrl: e,
|
493
|
+
merchantWalletAddress: i,
|
494
494
|
// Pass wallet address to API service
|
495
|
-
merchantSolWalletAddress:
|
496
|
-
}),
|
495
|
+
merchantSolWalletAddress: c
|
496
|
+
}), r(!0), u && console.log("Coinley SDK initialized with:", {
|
497
497
|
apiKey: s,
|
498
|
-
apiUrl:
|
499
|
-
merchantWalletAddress:
|
500
|
-
merchantSolWalletAddress:
|
498
|
+
apiUrl: e,
|
499
|
+
merchantWalletAddress: i ? `${i.substring(0, 6)}...${i.substring(i.length - 4)}` : "Not provided",
|
500
|
+
merchantSolWalletAddress: c ? `${c.substring(0, 6)}...${c.substring(c.length - 4)}` : "Not provided"
|
501
501
|
});
|
502
502
|
} catch (m) {
|
503
|
-
|
503
|
+
a(m.message), u && console.error("Coinley SDK initialization error:", m);
|
504
504
|
}
|
505
|
-
}, [s,
|
506
|
-
const
|
505
|
+
}, [s, t, e, i, c, u]);
|
506
|
+
const h = {
|
507
507
|
apiKey: s,
|
508
|
-
apiSecret:
|
509
|
-
apiUrl:
|
510
|
-
merchantWalletAddress:
|
511
|
-
merchantSolWalletAddress:
|
512
|
-
isInitialized:
|
508
|
+
apiSecret: t,
|
509
|
+
apiUrl: e,
|
510
|
+
merchantWalletAddress: i,
|
511
|
+
merchantSolWalletAddress: c,
|
512
|
+
isInitialized: x,
|
513
513
|
error: n,
|
514
|
-
debug:
|
515
|
-
paymentData:
|
516
|
-
storePaymentData: (m) => (
|
514
|
+
debug: u,
|
515
|
+
paymentData: l,
|
516
|
+
storePaymentData: (m) => (d(m), m)
|
517
517
|
};
|
518
|
-
return /* @__PURE__ */
|
518
|
+
return /* @__PURE__ */ o.jsx(ke.Provider, { value: h, children: y });
|
519
519
|
};
|
520
|
-
var
|
521
|
-
for (var
|
522
|
-
|
520
|
+
var Nt = Object.defineProperty, se = Object.getOwnPropertySymbols, Te = Object.prototype.hasOwnProperty, Ae = Object.prototype.propertyIsEnumerable, pe = (s, t, e) => t in s ? Nt(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, le = (s, t) => {
|
521
|
+
for (var e in t || (t = {}))
|
522
|
+
Te.call(t, e) && pe(s, e, t[e]);
|
523
523
|
if (se)
|
524
|
-
for (var
|
525
|
-
|
524
|
+
for (var e of se(t))
|
525
|
+
Ae.call(t, e) && pe(s, e, t[e]);
|
526
526
|
return s;
|
527
|
-
}, ce = (s,
|
528
|
-
var
|
529
|
-
for (var
|
530
|
-
|
527
|
+
}, ce = (s, t) => {
|
528
|
+
var e = {};
|
529
|
+
for (var i in s)
|
530
|
+
Te.call(s, i) && t.indexOf(i) < 0 && (e[i] = s[i]);
|
531
531
|
if (s != null && se)
|
532
|
-
for (var
|
533
|
-
|
534
|
-
return
|
532
|
+
for (var i of se(s))
|
533
|
+
t.indexOf(i) < 0 && Ae.call(s, i) && (e[i] = s[i]);
|
534
|
+
return e;
|
535
535
|
};
|
536
536
|
/**
|
537
537
|
* @license QR Code generator library (TypeScript)
|
@@ -540,34 +540,34 @@ var Et = Object.defineProperty, se = Object.getOwnPropertySymbols, Ce = Object.p
|
|
540
540
|
*/
|
541
541
|
var K;
|
542
542
|
((s) => {
|
543
|
-
const
|
543
|
+
const t = class E {
|
544
544
|
/*-- Constructor (low level) and fields --*/
|
545
545
|
// Creates a new QR Code with the given version number,
|
546
546
|
// error correction level, data codeword bytes, and mask number.
|
547
547
|
// This is a low-level API that most users should not use directly.
|
548
548
|
// A mid-level API is the encodeSegments() function.
|
549
|
-
constructor(
|
550
|
-
if (this.version =
|
549
|
+
constructor(r, n, a, l) {
|
550
|
+
if (this.version = r, this.errorCorrectionLevel = n, this.modules = [], this.isFunction = [], r < E.MIN_VERSION || r > E.MAX_VERSION)
|
551
551
|
throw new RangeError("Version value out of range");
|
552
|
-
if (
|
552
|
+
if (l < -1 || l > 7)
|
553
553
|
throw new RangeError("Mask value out of range");
|
554
|
-
this.size =
|
555
|
-
let
|
556
|
-
for (let
|
557
|
-
|
558
|
-
for (let
|
559
|
-
this.modules.push(
|
554
|
+
this.size = r * 4 + 17;
|
555
|
+
let d = [];
|
556
|
+
for (let h = 0; h < this.size; h++)
|
557
|
+
d.push(!1);
|
558
|
+
for (let h = 0; h < this.size; h++)
|
559
|
+
this.modules.push(d.slice()), this.isFunction.push(d.slice());
|
560
560
|
this.drawFunctionPatterns();
|
561
|
-
const
|
562
|
-
if (this.drawCodewords(
|
563
|
-
let
|
561
|
+
const g = this.addEccAndInterleave(a);
|
562
|
+
if (this.drawCodewords(g), l == -1) {
|
563
|
+
let h = 1e9;
|
564
564
|
for (let m = 0; m < 8; m++) {
|
565
565
|
this.applyMask(m), this.drawFormatBits(m);
|
566
|
-
const
|
567
|
-
|
566
|
+
const f = this.getPenaltyScore();
|
567
|
+
f < h && (l = m, h = f), this.applyMask(m);
|
568
568
|
}
|
569
569
|
}
|
570
|
-
|
570
|
+
c(0 <= l && l <= 7), this.mask = l, this.applyMask(l), this.drawFormatBits(l), this.isFunction = [];
|
571
571
|
}
|
572
572
|
/*-- Static factory functions (high level) --*/
|
573
573
|
// Returns a QR Code representing the given Unicode text string at the given error correction level.
|
@@ -575,17 +575,17 @@ var K;
|
|
575
575
|
// Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
|
576
576
|
// QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
|
577
577
|
// ecl argument if it can be done without increasing the version.
|
578
|
-
static encodeText(
|
579
|
-
const
|
580
|
-
return E.encodeSegments(
|
578
|
+
static encodeText(r, n) {
|
579
|
+
const a = s.QrSegment.makeSegments(r);
|
580
|
+
return E.encodeSegments(a, n);
|
581
581
|
}
|
582
582
|
// Returns a QR Code representing the given binary data at the given error correction level.
|
583
583
|
// This function always encodes using the binary segment mode, not any text mode. The maximum number of
|
584
584
|
// bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
|
585
585
|
// The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
|
586
|
-
static encodeBinary(
|
587
|
-
const
|
588
|
-
return E.encodeSegments([
|
586
|
+
static encodeBinary(r, n) {
|
587
|
+
const a = s.QrSegment.makeBytes(r);
|
588
|
+
return E.encodeSegments([a], n);
|
589
589
|
}
|
590
590
|
/*-- Static factory functions (mid level) --*/
|
591
591
|
// Returns a QR Code representing the given segments with the given encoding parameters.
|
@@ -597,43 +597,43 @@ var K;
|
|
597
597
|
// This function allows the user to create a custom sequence of segments that switches
|
598
598
|
// between modes (such as alphanumeric and byte) to encode text in less space.
|
599
599
|
// This is a mid-level API; the high-level API is encodeText() and encodeBinary().
|
600
|
-
static encodeSegments(
|
601
|
-
if (!(E.MIN_VERSION <=
|
600
|
+
static encodeSegments(r, n, a = 1, l = 40, d = -1, g = !0) {
|
601
|
+
if (!(E.MIN_VERSION <= a && a <= l && l <= E.MAX_VERSION) || d < -1 || d > 7)
|
602
602
|
throw new RangeError("Invalid value");
|
603
|
-
let
|
604
|
-
for (
|
605
|
-
const p = E.getNumDataCodewords(
|
606
|
-
if (
|
607
|
-
m =
|
603
|
+
let h, m;
|
604
|
+
for (h = a; ; h++) {
|
605
|
+
const p = E.getNumDataCodewords(h, n) * 8, T = y.getTotalBits(r, h);
|
606
|
+
if (T <= p) {
|
607
|
+
m = T;
|
608
608
|
break;
|
609
609
|
}
|
610
|
-
if (
|
610
|
+
if (h >= l)
|
611
611
|
throw new RangeError("Data too long");
|
612
612
|
}
|
613
613
|
for (const p of [E.Ecc.MEDIUM, E.Ecc.QUARTILE, E.Ecc.HIGH])
|
614
|
-
|
615
|
-
let
|
616
|
-
for (const p of
|
617
|
-
|
618
|
-
for (const
|
619
|
-
|
614
|
+
g && m <= E.getNumDataCodewords(h, p) * 8 && (n = p);
|
615
|
+
let f = [];
|
616
|
+
for (const p of r) {
|
617
|
+
e(p.mode.modeBits, 4, f), e(p.numChars, p.mode.numCharCountBits(h), f);
|
618
|
+
for (const T of p.getData())
|
619
|
+
f.push(T);
|
620
620
|
}
|
621
|
-
|
622
|
-
const
|
623
|
-
|
624
|
-
for (let p = 236;
|
625
|
-
|
626
|
-
let
|
627
|
-
for (;
|
628
|
-
|
629
|
-
return
|
621
|
+
c(f.length == m);
|
622
|
+
const k = E.getNumDataCodewords(h, n) * 8;
|
623
|
+
c(f.length <= k), e(0, Math.min(4, k - f.length), f), e(0, (8 - f.length % 8) % 8, f), c(f.length % 8 == 0);
|
624
|
+
for (let p = 236; f.length < k; p ^= 253)
|
625
|
+
e(p, 8, f);
|
626
|
+
let w = [];
|
627
|
+
for (; w.length * 8 < f.length; )
|
628
|
+
w.push(0);
|
629
|
+
return f.forEach((p, T) => w[T >>> 3] |= p << 7 - (T & 7)), new E(h, n, w, d);
|
630
630
|
}
|
631
631
|
/*-- Accessor methods --*/
|
632
632
|
// Returns the color of the module (pixel) at the given coordinates, which is false
|
633
633
|
// for light or true for dark. The top left corner has the coordinates (x=0, y=0).
|
634
634
|
// If the given coordinates are out of bounds, then false (light) is returned.
|
635
|
-
getModule(
|
636
|
-
return 0 <=
|
635
|
+
getModule(r, n) {
|
636
|
+
return 0 <= r && r < this.size && 0 <= n && n < this.size && this.modules[n][r];
|
637
637
|
}
|
638
638
|
// Modified to expose modules for easy access
|
639
639
|
getModules() {
|
@@ -642,33 +642,33 @@ var K;
|
|
642
642
|
/*-- Private helper methods for constructor: Drawing function modules --*/
|
643
643
|
// Reads this object's version field, and draws and marks all function modules.
|
644
644
|
drawFunctionPatterns() {
|
645
|
-
for (let
|
646
|
-
this.setFunctionModule(6,
|
645
|
+
for (let a = 0; a < this.size; a++)
|
646
|
+
this.setFunctionModule(6, a, a % 2 == 0), this.setFunctionModule(a, 6, a % 2 == 0);
|
647
647
|
this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
|
648
|
-
const
|
649
|
-
for (let
|
650
|
-
for (let
|
651
|
-
|
648
|
+
const r = this.getAlignmentPatternPositions(), n = r.length;
|
649
|
+
for (let a = 0; a < n; a++)
|
650
|
+
for (let l = 0; l < n; l++)
|
651
|
+
a == 0 && l == 0 || a == 0 && l == n - 1 || a == n - 1 && l == 0 || this.drawAlignmentPattern(r[a], r[l]);
|
652
652
|
this.drawFormatBits(0), this.drawVersion();
|
653
653
|
}
|
654
654
|
// Draws two copies of the format bits (with its own error correction code)
|
655
655
|
// based on the given mask and this object's error correction level field.
|
656
|
-
drawFormatBits(
|
657
|
-
const n = this.errorCorrectionLevel.formatBits << 3 |
|
658
|
-
let
|
659
|
-
for (let
|
660
|
-
|
661
|
-
const
|
662
|
-
|
663
|
-
for (let
|
664
|
-
this.setFunctionModule(8,
|
665
|
-
this.setFunctionModule(8, 7,
|
666
|
-
for (let
|
667
|
-
this.setFunctionModule(14 -
|
668
|
-
for (let
|
669
|
-
this.setFunctionModule(this.size - 1 -
|
670
|
-
for (let
|
671
|
-
this.setFunctionModule(8, this.size - 15 +
|
656
|
+
drawFormatBits(r) {
|
657
|
+
const n = this.errorCorrectionLevel.formatBits << 3 | r;
|
658
|
+
let a = n;
|
659
|
+
for (let d = 0; d < 10; d++)
|
660
|
+
a = a << 1 ^ (a >>> 9) * 1335;
|
661
|
+
const l = (n << 10 | a) ^ 21522;
|
662
|
+
c(l >>> 15 == 0);
|
663
|
+
for (let d = 0; d <= 5; d++)
|
664
|
+
this.setFunctionModule(8, d, i(l, d));
|
665
|
+
this.setFunctionModule(8, 7, i(l, 6)), this.setFunctionModule(8, 8, i(l, 7)), this.setFunctionModule(7, 8, i(l, 8));
|
666
|
+
for (let d = 9; d < 15; d++)
|
667
|
+
this.setFunctionModule(14 - d, 8, i(l, d));
|
668
|
+
for (let d = 0; d < 8; d++)
|
669
|
+
this.setFunctionModule(this.size - 1 - d, 8, i(l, d));
|
670
|
+
for (let d = 8; d < 15; d++)
|
671
|
+
this.setFunctionModule(8, this.size - 15 + d, i(l, d));
|
672
672
|
this.setFunctionModule(8, this.size - 8, !0);
|
673
673
|
}
|
674
674
|
// Draws two copies of the version bits (with its own error correction code),
|
@@ -676,144 +676,144 @@ var K;
|
|
676
676
|
drawVersion() {
|
677
677
|
if (this.version < 7)
|
678
678
|
return;
|
679
|
-
let
|
680
|
-
for (let
|
681
|
-
|
682
|
-
const n = this.version << 12 |
|
683
|
-
|
684
|
-
for (let
|
685
|
-
const
|
686
|
-
this.setFunctionModule(
|
679
|
+
let r = this.version;
|
680
|
+
for (let a = 0; a < 12; a++)
|
681
|
+
r = r << 1 ^ (r >>> 11) * 7973;
|
682
|
+
const n = this.version << 12 | r;
|
683
|
+
c(n >>> 18 == 0);
|
684
|
+
for (let a = 0; a < 18; a++) {
|
685
|
+
const l = i(n, a), d = this.size - 11 + a % 3, g = Math.floor(a / 3);
|
686
|
+
this.setFunctionModule(d, g, l), this.setFunctionModule(g, d, l);
|
687
687
|
}
|
688
688
|
}
|
689
689
|
// Draws a 9*9 finder pattern including the border separator,
|
690
690
|
// with the center module at (x, y). Modules can be out of bounds.
|
691
|
-
drawFinderPattern(
|
692
|
-
for (let
|
693
|
-
for (let
|
694
|
-
const
|
695
|
-
0 <=
|
691
|
+
drawFinderPattern(r, n) {
|
692
|
+
for (let a = -4; a <= 4; a++)
|
693
|
+
for (let l = -4; l <= 4; l++) {
|
694
|
+
const d = Math.max(Math.abs(l), Math.abs(a)), g = r + l, h = n + a;
|
695
|
+
0 <= g && g < this.size && 0 <= h && h < this.size && this.setFunctionModule(g, h, d != 2 && d != 4);
|
696
696
|
}
|
697
697
|
}
|
698
698
|
// Draws a 5*5 alignment pattern, with the center module
|
699
699
|
// at (x, y). All modules must be in bounds.
|
700
|
-
drawAlignmentPattern(
|
701
|
-
for (let
|
702
|
-
for (let
|
703
|
-
this.setFunctionModule(
|
700
|
+
drawAlignmentPattern(r, n) {
|
701
|
+
for (let a = -2; a <= 2; a++)
|
702
|
+
for (let l = -2; l <= 2; l++)
|
703
|
+
this.setFunctionModule(r + l, n + a, Math.max(Math.abs(l), Math.abs(a)) != 1);
|
704
704
|
}
|
705
705
|
// Sets the color of a module and marks it as a function module.
|
706
706
|
// Only used by the constructor. Coordinates must be in bounds.
|
707
|
-
setFunctionModule(
|
708
|
-
this.modules[n][
|
707
|
+
setFunctionModule(r, n, a) {
|
708
|
+
this.modules[n][r] = a, this.isFunction[n][r] = !0;
|
709
709
|
}
|
710
710
|
/*-- Private helper methods for constructor: Codewords and masking --*/
|
711
711
|
// Returns a new byte string representing the given data with the appropriate error correction
|
712
712
|
// codewords appended to it, based on this object's version and error correction level.
|
713
|
-
addEccAndInterleave(
|
714
|
-
const n = this.version,
|
715
|
-
if (
|
713
|
+
addEccAndInterleave(r) {
|
714
|
+
const n = this.version, a = this.errorCorrectionLevel;
|
715
|
+
if (r.length != E.getNumDataCodewords(n, a))
|
716
716
|
throw new RangeError("Invalid argument");
|
717
|
-
const
|
718
|
-
let
|
719
|
-
const
|
720
|
-
for (let p = 0,
|
721
|
-
let
|
722
|
-
|
723
|
-
const
|
724
|
-
p <
|
717
|
+
const l = E.NUM_ERROR_CORRECTION_BLOCKS[a.ordinal][n], d = E.ECC_CODEWORDS_PER_BLOCK[a.ordinal][n], g = Math.floor(E.getNumRawDataModules(n) / 8), h = l - g % l, m = Math.floor(g / l);
|
718
|
+
let f = [];
|
719
|
+
const k = E.reedSolomonComputeDivisor(d);
|
720
|
+
for (let p = 0, T = 0; p < l; p++) {
|
721
|
+
let C = r.slice(T, T + m - d + (p < h ? 0 : 1));
|
722
|
+
T += C.length;
|
723
|
+
const q = E.reedSolomonComputeRemainder(C, k);
|
724
|
+
p < h && C.push(0), f.push(C.concat(q));
|
725
725
|
}
|
726
|
-
let
|
727
|
-
for (let p = 0; p <
|
728
|
-
|
729
|
-
(p != m -
|
726
|
+
let w = [];
|
727
|
+
for (let p = 0; p < f[0].length; p++)
|
728
|
+
f.forEach((T, C) => {
|
729
|
+
(p != m - d || C >= h) && w.push(T[p]);
|
730
730
|
});
|
731
|
-
return
|
731
|
+
return c(w.length == g), w;
|
732
732
|
}
|
733
733
|
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
|
734
734
|
// data area of this QR Code. Function modules need to be marked off before this is called.
|
735
|
-
drawCodewords(
|
736
|
-
if (
|
735
|
+
drawCodewords(r) {
|
736
|
+
if (r.length != Math.floor(E.getNumRawDataModules(this.version) / 8))
|
737
737
|
throw new RangeError("Invalid argument");
|
738
738
|
let n = 0;
|
739
|
-
for (let
|
740
|
-
|
741
|
-
for (let
|
742
|
-
for (let
|
743
|
-
const
|
744
|
-
!this.isFunction[m][
|
739
|
+
for (let a = this.size - 1; a >= 1; a -= 2) {
|
740
|
+
a == 6 && (a = 5);
|
741
|
+
for (let l = 0; l < this.size; l++)
|
742
|
+
for (let d = 0; d < 2; d++) {
|
743
|
+
const g = a - d, m = (a + 1 & 2) == 0 ? this.size - 1 - l : l;
|
744
|
+
!this.isFunction[m][g] && n < r.length * 8 && (this.modules[m][g] = i(r[n >>> 3], 7 - (n & 7)), n++);
|
745
745
|
}
|
746
746
|
}
|
747
|
-
|
747
|
+
c(n == r.length * 8);
|
748
748
|
}
|
749
749
|
// XORs the codeword modules in this QR Code with the given mask pattern.
|
750
750
|
// The function modules must be marked and the codeword bits must be drawn
|
751
751
|
// before masking. Due to the arithmetic of XOR, calling applyMask() with
|
752
752
|
// the same mask value a second time will undo the mask. A final well-formed
|
753
753
|
// QR Code needs exactly one (not zero, two, etc.) mask applied.
|
754
|
-
applyMask(
|
755
|
-
if (
|
754
|
+
applyMask(r) {
|
755
|
+
if (r < 0 || r > 7)
|
756
756
|
throw new RangeError("Mask value out of range");
|
757
757
|
for (let n = 0; n < this.size; n++)
|
758
|
-
for (let
|
759
|
-
let
|
760
|
-
switch (
|
758
|
+
for (let a = 0; a < this.size; a++) {
|
759
|
+
let l;
|
760
|
+
switch (r) {
|
761
761
|
case 0:
|
762
|
-
|
762
|
+
l = (a + n) % 2 == 0;
|
763
763
|
break;
|
764
764
|
case 1:
|
765
|
-
|
765
|
+
l = n % 2 == 0;
|
766
766
|
break;
|
767
767
|
case 2:
|
768
|
-
|
768
|
+
l = a % 3 == 0;
|
769
769
|
break;
|
770
770
|
case 3:
|
771
|
-
|
771
|
+
l = (a + n) % 3 == 0;
|
772
772
|
break;
|
773
773
|
case 4:
|
774
|
-
|
774
|
+
l = (Math.floor(a / 3) + Math.floor(n / 2)) % 2 == 0;
|
775
775
|
break;
|
776
776
|
case 5:
|
777
|
-
|
777
|
+
l = a * n % 2 + a * n % 3 == 0;
|
778
778
|
break;
|
779
779
|
case 6:
|
780
|
-
|
780
|
+
l = (a * n % 2 + a * n % 3) % 2 == 0;
|
781
781
|
break;
|
782
782
|
case 7:
|
783
|
-
|
783
|
+
l = ((a + n) % 2 + a * n % 3) % 2 == 0;
|
784
784
|
break;
|
785
785
|
default:
|
786
786
|
throw new Error("Unreachable");
|
787
787
|
}
|
788
|
-
!this.isFunction[n][
|
788
|
+
!this.isFunction[n][a] && l && (this.modules[n][a] = !this.modules[n][a]);
|
789
789
|
}
|
790
790
|
}
|
791
791
|
// Calculates and returns the penalty score based on state of this QR Code's current modules.
|
792
792
|
// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
|
793
793
|
getPenaltyScore() {
|
794
|
-
let
|
795
|
-
for (let
|
796
|
-
let
|
797
|
-
for (let
|
798
|
-
this.modules[
|
799
|
-
|
794
|
+
let r = 0;
|
795
|
+
for (let d = 0; d < this.size; d++) {
|
796
|
+
let g = !1, h = 0, m = [0, 0, 0, 0, 0, 0, 0];
|
797
|
+
for (let f = 0; f < this.size; f++)
|
798
|
+
this.modules[d][f] == g ? (h++, h == 5 ? r += E.PENALTY_N1 : h > 5 && r++) : (this.finderPenaltyAddHistory(h, m), g || (r += this.finderPenaltyCountPatterns(m) * E.PENALTY_N3), g = this.modules[d][f], h = 1);
|
799
|
+
r += this.finderPenaltyTerminateAndCount(g, h, m) * E.PENALTY_N3;
|
800
800
|
}
|
801
|
-
for (let
|
802
|
-
let
|
803
|
-
for (let
|
804
|
-
this.modules[
|
805
|
-
|
801
|
+
for (let d = 0; d < this.size; d++) {
|
802
|
+
let g = !1, h = 0, m = [0, 0, 0, 0, 0, 0, 0];
|
803
|
+
for (let f = 0; f < this.size; f++)
|
804
|
+
this.modules[f][d] == g ? (h++, h == 5 ? r += E.PENALTY_N1 : h > 5 && r++) : (this.finderPenaltyAddHistory(h, m), g || (r += this.finderPenaltyCountPatterns(m) * E.PENALTY_N3), g = this.modules[f][d], h = 1);
|
805
|
+
r += this.finderPenaltyTerminateAndCount(g, h, m) * E.PENALTY_N3;
|
806
806
|
}
|
807
|
-
for (let
|
808
|
-
for (let
|
809
|
-
const
|
810
|
-
|
807
|
+
for (let d = 0; d < this.size - 1; d++)
|
808
|
+
for (let g = 0; g < this.size - 1; g++) {
|
809
|
+
const h = this.modules[d][g];
|
810
|
+
h == this.modules[d][g + 1] && h == this.modules[d + 1][g] && h == this.modules[d + 1][g + 1] && (r += E.PENALTY_N2);
|
811
811
|
}
|
812
812
|
let n = 0;
|
813
|
-
for (const
|
814
|
-
n =
|
815
|
-
const
|
816
|
-
return
|
813
|
+
for (const d of this.modules)
|
814
|
+
n = d.reduce((g, h) => g + (h ? 1 : 0), n);
|
815
|
+
const a = this.size * this.size, l = Math.ceil(Math.abs(n * 20 - a * 10) / a) - 1;
|
816
|
+
return c(0 <= l && l <= 9), r += l * E.PENALTY_N4, c(0 <= r && r <= 2568888), r;
|
817
817
|
}
|
818
818
|
/*-- Private helper functions --*/
|
819
819
|
// Returns an ascending list of positions of alignment patterns for this version number.
|
@@ -823,86 +823,86 @@ var K;
|
|
823
823
|
if (this.version == 1)
|
824
824
|
return [];
|
825
825
|
{
|
826
|
-
const
|
827
|
-
let
|
828
|
-
for (let
|
829
|
-
|
830
|
-
return
|
826
|
+
const r = Math.floor(this.version / 7) + 2, n = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (r * 2 - 2)) * 2;
|
827
|
+
let a = [6];
|
828
|
+
for (let l = this.size - 7; a.length < r; l -= n)
|
829
|
+
a.splice(1, 0, l);
|
830
|
+
return a;
|
831
831
|
}
|
832
832
|
}
|
833
833
|
// Returns the number of data bits that can be stored in a QR Code of the given version number, after
|
834
834
|
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
|
835
835
|
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
|
836
|
-
static getNumRawDataModules(
|
837
|
-
if (
|
836
|
+
static getNumRawDataModules(r) {
|
837
|
+
if (r < E.MIN_VERSION || r > E.MAX_VERSION)
|
838
838
|
throw new RangeError("Version number out of range");
|
839
|
-
let n = (16 *
|
840
|
-
if (
|
841
|
-
const
|
842
|
-
n -= (25 *
|
839
|
+
let n = (16 * r + 128) * r + 64;
|
840
|
+
if (r >= 2) {
|
841
|
+
const a = Math.floor(r / 7) + 2;
|
842
|
+
n -= (25 * a - 10) * a - 55, r >= 7 && (n -= 36);
|
843
843
|
}
|
844
|
-
return
|
844
|
+
return c(208 <= n && n <= 29648), n;
|
845
845
|
}
|
846
846
|
// Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
|
847
847
|
// QR Code of the given version number and error correction level, with remainder bits discarded.
|
848
848
|
// This stateless pure function could be implemented as a (40*4)-cell lookup table.
|
849
|
-
static getNumDataCodewords(
|
850
|
-
return Math.floor(E.getNumRawDataModules(
|
849
|
+
static getNumDataCodewords(r, n) {
|
850
|
+
return Math.floor(E.getNumRawDataModules(r) / 8) - E.ECC_CODEWORDS_PER_BLOCK[n.ordinal][r] * E.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][r];
|
851
851
|
}
|
852
852
|
// Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
|
853
853
|
// implemented as a lookup table over all possible parameter values, instead of as an algorithm.
|
854
|
-
static reedSolomonComputeDivisor(
|
855
|
-
if (
|
854
|
+
static reedSolomonComputeDivisor(r) {
|
855
|
+
if (r < 1 || r > 255)
|
856
856
|
throw new RangeError("Degree out of range");
|
857
857
|
let n = [];
|
858
|
-
for (let
|
858
|
+
for (let l = 0; l < r - 1; l++)
|
859
859
|
n.push(0);
|
860
860
|
n.push(1);
|
861
|
-
let
|
862
|
-
for (let
|
863
|
-
for (let
|
864
|
-
n[
|
865
|
-
|
861
|
+
let a = 1;
|
862
|
+
for (let l = 0; l < r; l++) {
|
863
|
+
for (let d = 0; d < n.length; d++)
|
864
|
+
n[d] = E.reedSolomonMultiply(n[d], a), d + 1 < n.length && (n[d] ^= n[d + 1]);
|
865
|
+
a = E.reedSolomonMultiply(a, 2);
|
866
866
|
}
|
867
867
|
return n;
|
868
868
|
}
|
869
869
|
// Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
|
870
|
-
static reedSolomonComputeRemainder(
|
871
|
-
let
|
872
|
-
for (const
|
873
|
-
const
|
874
|
-
|
870
|
+
static reedSolomonComputeRemainder(r, n) {
|
871
|
+
let a = n.map((l) => 0);
|
872
|
+
for (const l of r) {
|
873
|
+
const d = l ^ a.shift();
|
874
|
+
a.push(0), n.forEach((g, h) => a[h] ^= E.reedSolomonMultiply(g, d));
|
875
875
|
}
|
876
|
-
return
|
876
|
+
return a;
|
877
877
|
}
|
878
878
|
// Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
|
879
879
|
// are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
|
880
|
-
static reedSolomonMultiply(
|
881
|
-
if (
|
880
|
+
static reedSolomonMultiply(r, n) {
|
881
|
+
if (r >>> 8 || n >>> 8)
|
882
882
|
throw new RangeError("Byte out of range");
|
883
|
-
let
|
884
|
-
for (let
|
885
|
-
|
886
|
-
return
|
883
|
+
let a = 0;
|
884
|
+
for (let l = 7; l >= 0; l--)
|
885
|
+
a = a << 1 ^ (a >>> 7) * 285, a ^= (n >>> l & 1) * r;
|
886
|
+
return c(a >>> 8 == 0), a;
|
887
887
|
}
|
888
888
|
// Can only be called immediately after a light run is added, and
|
889
889
|
// returns either 0, 1, or 2. A helper function for getPenaltyScore().
|
890
|
-
finderPenaltyCountPatterns(
|
891
|
-
const n =
|
892
|
-
|
893
|
-
const
|
894
|
-
return (
|
890
|
+
finderPenaltyCountPatterns(r) {
|
891
|
+
const n = r[1];
|
892
|
+
c(n <= this.size * 3);
|
893
|
+
const a = n > 0 && r[2] == n && r[3] == n * 3 && r[4] == n && r[5] == n;
|
894
|
+
return (a && r[0] >= n * 4 && r[6] >= n ? 1 : 0) + (a && r[6] >= n * 4 && r[0] >= n ? 1 : 0);
|
895
895
|
}
|
896
896
|
// Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
|
897
|
-
finderPenaltyTerminateAndCount(
|
898
|
-
return
|
897
|
+
finderPenaltyTerminateAndCount(r, n, a) {
|
898
|
+
return r && (this.finderPenaltyAddHistory(n, a), n = 0), n += this.size, this.finderPenaltyAddHistory(n, a), this.finderPenaltyCountPatterns(a);
|
899
899
|
}
|
900
900
|
// Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
|
901
|
-
finderPenaltyAddHistory(
|
902
|
-
n[0] == 0 && (
|
901
|
+
finderPenaltyAddHistory(r, n) {
|
902
|
+
n[0] == 0 && (r += this.size), n.pop(), n.unshift(r);
|
903
903
|
}
|
904
904
|
};
|
905
|
-
|
905
|
+
t.MIN_VERSION = 1, t.MAX_VERSION = 40, t.PENALTY_N1 = 3, t.PENALTY_N2 = 3, t.PENALTY_N3 = 40, t.PENALTY_N4 = 10, t.ECC_CODEWORDS_PER_BLOCK = [
|
906
906
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
907
907
|
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
908
908
|
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
@@ -913,7 +913,7 @@ var K;
|
|
913
913
|
// Quartile
|
914
914
|
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
|
915
915
|
// High
|
916
|
-
],
|
916
|
+
], t.NUM_ERROR_CORRECTION_BLOCKS = [
|
917
917
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
918
918
|
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
919
919
|
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
@@ -924,95 +924,95 @@ var K;
|
|
924
924
|
// Quartile
|
925
925
|
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
|
926
926
|
// High
|
927
|
-
], s.QrCode =
|
928
|
-
function
|
929
|
-
if (
|
927
|
+
], s.QrCode = t;
|
928
|
+
function e(x, r, n) {
|
929
|
+
if (r < 0 || r > 31 || x >>> r)
|
930
930
|
throw new RangeError("Value out of range");
|
931
|
-
for (let
|
932
|
-
n.push(
|
931
|
+
for (let a = r - 1; a >= 0; a--)
|
932
|
+
n.push(x >>> a & 1);
|
933
933
|
}
|
934
|
-
function
|
935
|
-
return (
|
934
|
+
function i(x, r) {
|
935
|
+
return (x >>> r & 1) != 0;
|
936
936
|
}
|
937
|
-
function
|
938
|
-
if (!
|
937
|
+
function c(x) {
|
938
|
+
if (!x)
|
939
939
|
throw new Error("Assertion error");
|
940
940
|
}
|
941
|
-
const
|
941
|
+
const u = class j {
|
942
942
|
/*-- Constructor (low level) and fields --*/
|
943
943
|
// Creates a new QR Code segment with the given attributes and data.
|
944
944
|
// The character count (numChars) must agree with the mode and the bit buffer length,
|
945
945
|
// but the constraint isn't checked. The given bit buffer is cloned and stored.
|
946
|
-
constructor(
|
947
|
-
if (this.mode =
|
946
|
+
constructor(r, n, a) {
|
947
|
+
if (this.mode = r, this.numChars = n, this.bitData = a, n < 0)
|
948
948
|
throw new RangeError("Invalid argument");
|
949
|
-
this.bitData =
|
949
|
+
this.bitData = a.slice();
|
950
950
|
}
|
951
951
|
/*-- Static factory functions (mid level) --*/
|
952
952
|
// Returns a segment representing the given binary data encoded in
|
953
953
|
// byte mode. All input byte arrays are acceptable. Any text string
|
954
954
|
// can be converted to UTF-8 bytes and encoded as a byte mode segment.
|
955
|
-
static makeBytes(
|
955
|
+
static makeBytes(r) {
|
956
956
|
let n = [];
|
957
|
-
for (const
|
958
|
-
|
959
|
-
return new
|
957
|
+
for (const a of r)
|
958
|
+
e(a, 8, n);
|
959
|
+
return new j(j.Mode.BYTE, r.length, n);
|
960
960
|
}
|
961
961
|
// Returns a segment representing the given string of decimal digits encoded in numeric mode.
|
962
|
-
static makeNumeric(
|
963
|
-
if (!
|
962
|
+
static makeNumeric(r) {
|
963
|
+
if (!j.isNumeric(r))
|
964
964
|
throw new RangeError("String contains non-numeric characters");
|
965
965
|
let n = [];
|
966
|
-
for (let
|
967
|
-
const
|
968
|
-
|
966
|
+
for (let a = 0; a < r.length; ) {
|
967
|
+
const l = Math.min(r.length - a, 3);
|
968
|
+
e(parseInt(r.substring(a, a + l), 10), l * 3 + 1, n), a += l;
|
969
969
|
}
|
970
|
-
return new
|
970
|
+
return new j(j.Mode.NUMERIC, r.length, n);
|
971
971
|
}
|
972
972
|
// Returns a segment representing the given text string encoded in alphanumeric mode.
|
973
973
|
// The characters allowed are: 0 to 9, A to Z (uppercase only), space,
|
974
974
|
// dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
975
|
-
static makeAlphanumeric(
|
976
|
-
if (!
|
975
|
+
static makeAlphanumeric(r) {
|
976
|
+
if (!j.isAlphanumeric(r))
|
977
977
|
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
978
|
-
let n = [],
|
979
|
-
for (
|
980
|
-
let
|
981
|
-
|
978
|
+
let n = [], a;
|
979
|
+
for (a = 0; a + 2 <= r.length; a += 2) {
|
980
|
+
let l = j.ALPHANUMERIC_CHARSET.indexOf(r.charAt(a)) * 45;
|
981
|
+
l += j.ALPHANUMERIC_CHARSET.indexOf(r.charAt(a + 1)), e(l, 11, n);
|
982
982
|
}
|
983
|
-
return
|
983
|
+
return a < r.length && e(j.ALPHANUMERIC_CHARSET.indexOf(r.charAt(a)), 6, n), new j(j.Mode.ALPHANUMERIC, r.length, n);
|
984
984
|
}
|
985
985
|
// Returns a new mutable list of zero or more segments to represent the given Unicode text string.
|
986
986
|
// The result may use various segment modes and switch modes to optimize the length of the bit stream.
|
987
|
-
static makeSegments(
|
988
|
-
return
|
987
|
+
static makeSegments(r) {
|
988
|
+
return r == "" ? [] : j.isNumeric(r) ? [j.makeNumeric(r)] : j.isAlphanumeric(r) ? [j.makeAlphanumeric(r)] : [j.makeBytes(j.toUtf8ByteArray(r))];
|
989
989
|
}
|
990
990
|
// Returns a segment representing an Extended Channel Interpretation
|
991
991
|
// (ECI) designator with the given assignment value.
|
992
|
-
static makeEci(
|
992
|
+
static makeEci(r) {
|
993
993
|
let n = [];
|
994
|
-
if (
|
994
|
+
if (r < 0)
|
995
995
|
throw new RangeError("ECI assignment value out of range");
|
996
|
-
if (
|
997
|
-
|
998
|
-
else if (
|
999
|
-
|
1000
|
-
else if (
|
1001
|
-
|
996
|
+
if (r < 128)
|
997
|
+
e(r, 8, n);
|
998
|
+
else if (r < 16384)
|
999
|
+
e(2, 2, n), e(r, 14, n);
|
1000
|
+
else if (r < 1e6)
|
1001
|
+
e(6, 3, n), e(r, 21, n);
|
1002
1002
|
else
|
1003
1003
|
throw new RangeError("ECI assignment value out of range");
|
1004
|
-
return new
|
1004
|
+
return new j(j.Mode.ECI, 0, n);
|
1005
1005
|
}
|
1006
1006
|
// Tests whether the given string can be encoded as a segment in numeric mode.
|
1007
1007
|
// A string is encodable iff each character is in the range 0 to 9.
|
1008
|
-
static isNumeric(
|
1009
|
-
return
|
1008
|
+
static isNumeric(r) {
|
1009
|
+
return j.NUMERIC_REGEX.test(r);
|
1010
1010
|
}
|
1011
1011
|
// Tests whether the given string can be encoded as a segment in alphanumeric mode.
|
1012
1012
|
// A string is encodable iff each character is in the following set: 0 to 9, A to Z
|
1013
1013
|
// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
1014
|
-
static isAlphanumeric(
|
1015
|
-
return
|
1014
|
+
static isAlphanumeric(r) {
|
1015
|
+
return j.ALPHANUMERIC_REGEX.test(r);
|
1016
1016
|
}
|
1017
1017
|
/*-- Methods --*/
|
1018
1018
|
// Returns a new copy of the data bits of this segment.
|
@@ -1021,176 +1021,176 @@ var K;
|
|
1021
1021
|
}
|
1022
1022
|
// (Package-private) Calculates and returns the number of bits needed to encode the given segments at
|
1023
1023
|
// the given version. The result is infinity if a segment has too many characters to fit its length field.
|
1024
|
-
static getTotalBits(
|
1025
|
-
let
|
1026
|
-
for (const
|
1027
|
-
const
|
1028
|
-
if (
|
1024
|
+
static getTotalBits(r, n) {
|
1025
|
+
let a = 0;
|
1026
|
+
for (const l of r) {
|
1027
|
+
const d = l.mode.numCharCountBits(n);
|
1028
|
+
if (l.numChars >= 1 << d)
|
1029
1029
|
return 1 / 0;
|
1030
|
-
|
1030
|
+
a += 4 + d + l.bitData.length;
|
1031
1031
|
}
|
1032
|
-
return
|
1032
|
+
return a;
|
1033
1033
|
}
|
1034
1034
|
// Returns a new array of bytes representing the given string encoded in UTF-8.
|
1035
|
-
static toUtf8ByteArray(
|
1036
|
-
|
1035
|
+
static toUtf8ByteArray(r) {
|
1036
|
+
r = encodeURI(r);
|
1037
1037
|
let n = [];
|
1038
|
-
for (let
|
1039
|
-
|
1038
|
+
for (let a = 0; a < r.length; a++)
|
1039
|
+
r.charAt(a) != "%" ? n.push(r.charCodeAt(a)) : (n.push(parseInt(r.substring(a + 1, a + 3), 16)), a += 2);
|
1040
1040
|
return n;
|
1041
1041
|
}
|
1042
1042
|
};
|
1043
|
-
|
1044
|
-
let y =
|
1045
|
-
s.QrSegment =
|
1043
|
+
u.NUMERIC_REGEX = /^[0-9]*$/, u.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, u.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
1044
|
+
let y = u;
|
1045
|
+
s.QrSegment = u;
|
1046
1046
|
})(K || (K = {}));
|
1047
1047
|
((s) => {
|
1048
|
-
((
|
1049
|
-
const
|
1048
|
+
((t) => {
|
1049
|
+
const e = class {
|
1050
1050
|
// The QR Code can tolerate about 30% erroneous codewords
|
1051
1051
|
/*-- Constructor and fields --*/
|
1052
|
-
constructor(
|
1053
|
-
this.ordinal =
|
1052
|
+
constructor(c, u) {
|
1053
|
+
this.ordinal = c, this.formatBits = u;
|
1054
1054
|
}
|
1055
1055
|
};
|
1056
|
-
|
1056
|
+
e.LOW = new e(0, 1), e.MEDIUM = new e(1, 0), e.QUARTILE = new e(2, 3), e.HIGH = new e(3, 2), t.Ecc = e;
|
1057
1057
|
})(s.QrCode || (s.QrCode = {}));
|
1058
1058
|
})(K || (K = {}));
|
1059
1059
|
((s) => {
|
1060
|
-
((
|
1061
|
-
const
|
1060
|
+
((t) => {
|
1061
|
+
const e = class {
|
1062
1062
|
/*-- Constructor and fields --*/
|
1063
|
-
constructor(
|
1064
|
-
this.modeBits =
|
1063
|
+
constructor(c, u) {
|
1064
|
+
this.modeBits = c, this.numBitsCharCount = u;
|
1065
1065
|
}
|
1066
1066
|
/*-- Method --*/
|
1067
1067
|
// (Package-private) Returns the bit width of the character count field for a segment in
|
1068
1068
|
// this mode in a QR Code at the given version number. The result is in the range [0, 16].
|
1069
|
-
numCharCountBits(
|
1070
|
-
return this.numBitsCharCount[Math.floor((
|
1069
|
+
numCharCountBits(c) {
|
1070
|
+
return this.numBitsCharCount[Math.floor((c + 7) / 17)];
|
1071
1071
|
}
|
1072
1072
|
};
|
1073
|
-
|
1073
|
+
e.NUMERIC = new e(1, [10, 12, 14]), e.ALPHANUMERIC = new e(2, [9, 11, 13]), e.BYTE = new e(4, [8, 16, 16]), e.KANJI = new e(8, [8, 10, 12]), e.ECI = new e(7, [0, 0, 0]), t.Mode = e;
|
1074
1074
|
})(s.QrSegment || (s.QrSegment = {}));
|
1075
1075
|
})(K || (K = {}));
|
1076
|
-
var
|
1076
|
+
var J = K;
|
1077
1077
|
/**
|
1078
1078
|
* @license qrcode.react
|
1079
1079
|
* Copyright (c) Paul O'Shannessy
|
1080
1080
|
* SPDX-License-Identifier: ISC
|
1081
1081
|
*/
|
1082
|
-
var
|
1083
|
-
L:
|
1084
|
-
M:
|
1085
|
-
Q:
|
1086
|
-
H:
|
1087
|
-
},
|
1088
|
-
function
|
1089
|
-
const
|
1090
|
-
return s.forEach(function(
|
1091
|
-
let
|
1092
|
-
|
1093
|
-
if (!y &&
|
1094
|
-
|
1095
|
-
`M${
|
1096
|
-
),
|
1082
|
+
var Et = {
|
1083
|
+
L: J.QrCode.Ecc.LOW,
|
1084
|
+
M: J.QrCode.Ecc.MEDIUM,
|
1085
|
+
Q: J.QrCode.Ecc.QUARTILE,
|
1086
|
+
H: J.QrCode.Ecc.HIGH
|
1087
|
+
}, Ce = 128, je = "L", Me = "#FFFFFF", Re = "#000000", Se = !1, Le = 1, vt = 4, kt = 0, Tt = 0.1;
|
1088
|
+
function Pe(s, t = 0) {
|
1089
|
+
const e = [];
|
1090
|
+
return s.forEach(function(i, c) {
|
1091
|
+
let u = null;
|
1092
|
+
i.forEach(function(y, x) {
|
1093
|
+
if (!y && u !== null) {
|
1094
|
+
e.push(
|
1095
|
+
`M${u + t} ${c + t}h${x - u}v1H${u + t}z`
|
1096
|
+
), u = null;
|
1097
1097
|
return;
|
1098
1098
|
}
|
1099
|
-
if (
|
1099
|
+
if (x === i.length - 1) {
|
1100
1100
|
if (!y)
|
1101
1101
|
return;
|
1102
|
-
|
1103
|
-
`M${
|
1102
|
+
u === null ? e.push(`M${x + t},${c + t} h1v1H${x + t}z`) : e.push(
|
1103
|
+
`M${u + t},${c + t} h${x + 1 - u}v1H${u + t}z`
|
1104
1104
|
);
|
1105
1105
|
return;
|
1106
1106
|
}
|
1107
|
-
y &&
|
1107
|
+
y && u === null && (u = x);
|
1108
1108
|
});
|
1109
|
-
}),
|
1109
|
+
}), e.join("");
|
1110
1110
|
}
|
1111
|
-
function De(s,
|
1112
|
-
return s.slice().map((
|
1111
|
+
function De(s, t) {
|
1112
|
+
return s.slice().map((e, i) => i < t.y || i >= t.y + t.h ? e : e.map((c, u) => u < t.x || u >= t.x + t.w ? c : !1));
|
1113
1113
|
}
|
1114
|
-
function
|
1115
|
-
if (
|
1114
|
+
function At(s, t, e, i) {
|
1115
|
+
if (i == null)
|
1116
1116
|
return null;
|
1117
|
-
const
|
1118
|
-
let
|
1119
|
-
if (
|
1120
|
-
let
|
1121
|
-
|
1117
|
+
const c = s.length + e * 2, u = Math.floor(t * Tt), y = c / t, x = (i.width || u) * y, r = (i.height || u) * y, n = i.x == null ? s.length / 2 - x / 2 : i.x * y, a = i.y == null ? s.length / 2 - r / 2 : i.y * y, l = i.opacity == null ? 1 : i.opacity;
|
1118
|
+
let d = null;
|
1119
|
+
if (i.excavate) {
|
1120
|
+
let h = Math.floor(n), m = Math.floor(a), f = Math.ceil(x + n - h), k = Math.ceil(r + a - m);
|
1121
|
+
d = { x: h, y: m, w: f, h: k };
|
1122
1122
|
}
|
1123
|
-
const
|
1124
|
-
return { x: n, y:
|
1123
|
+
const g = i.crossOrigin;
|
1124
|
+
return { x: n, y: a, h: r, w: x, excavation: d, opacity: l, crossOrigin: g };
|
1125
1125
|
}
|
1126
|
-
function
|
1127
|
-
return
|
1126
|
+
function Ct(s, t) {
|
1127
|
+
return t != null ? Math.max(Math.floor(t), 0) : s ? vt : kt;
|
1128
1128
|
}
|
1129
1129
|
function Ue({
|
1130
1130
|
value: s,
|
1131
|
-
level:
|
1132
|
-
minVersion:
|
1133
|
-
includeMargin:
|
1134
|
-
marginSize:
|
1135
|
-
imageSettings:
|
1131
|
+
level: t,
|
1132
|
+
minVersion: e,
|
1133
|
+
includeMargin: i,
|
1134
|
+
marginSize: c,
|
1135
|
+
imageSettings: u,
|
1136
1136
|
size: y,
|
1137
|
-
boostLevel:
|
1137
|
+
boostLevel: x
|
1138
1138
|
}) {
|
1139
|
-
let
|
1140
|
-
const
|
1141
|
-
return
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1139
|
+
let r = L.useMemo(() => {
|
1140
|
+
const h = (Array.isArray(s) ? s : [s]).reduce((m, f) => (m.push(...J.QrSegment.makeSegments(f)), m), []);
|
1141
|
+
return J.QrCode.encodeSegments(
|
1142
|
+
h,
|
1143
|
+
Et[t],
|
1144
|
+
e,
|
1145
1145
|
void 0,
|
1146
1146
|
void 0,
|
1147
|
-
|
1147
|
+
x
|
1148
1148
|
);
|
1149
|
-
}, [s,
|
1150
|
-
const { cells: n, margin:
|
1151
|
-
let
|
1152
|
-
const
|
1153
|
-
|
1149
|
+
}, [s, t, e, x]);
|
1150
|
+
const { cells: n, margin: a, numCells: l, calculatedImageSettings: d } = L.useMemo(() => {
|
1151
|
+
let g = r.getModules();
|
1152
|
+
const h = Ct(i, c), m = g.length + h * 2, f = At(
|
1153
|
+
g,
|
1154
1154
|
y,
|
1155
|
-
|
1156
|
-
|
1155
|
+
h,
|
1156
|
+
u
|
1157
1157
|
);
|
1158
1158
|
return {
|
1159
|
-
cells:
|
1160
|
-
margin:
|
1159
|
+
cells: g,
|
1160
|
+
margin: h,
|
1161
1161
|
numCells: m,
|
1162
|
-
calculatedImageSettings:
|
1162
|
+
calculatedImageSettings: f
|
1163
1163
|
};
|
1164
|
-
}, [
|
1164
|
+
}, [r, y, u, i, c]);
|
1165
1165
|
return {
|
1166
|
-
qrcode:
|
1167
|
-
margin:
|
1166
|
+
qrcode: r,
|
1167
|
+
margin: a,
|
1168
1168
|
cells: n,
|
1169
|
-
numCells:
|
1170
|
-
calculatedImageSettings:
|
1169
|
+
numCells: l,
|
1170
|
+
calculatedImageSettings: d
|
1171
1171
|
};
|
1172
1172
|
}
|
1173
|
-
var
|
1173
|
+
var jt = function() {
|
1174
1174
|
try {
|
1175
1175
|
new Path2D().addPath(new Path2D());
|
1176
1176
|
} catch (s) {
|
1177
1177
|
return !1;
|
1178
1178
|
}
|
1179
1179
|
return !0;
|
1180
|
-
}(),
|
1181
|
-
function(
|
1182
|
-
const
|
1183
|
-
value:
|
1184
|
-
size:
|
1185
|
-
level: y =
|
1186
|
-
bgColor:
|
1187
|
-
fgColor:
|
1188
|
-
includeMargin: n =
|
1189
|
-
minVersion:
|
1190
|
-
boostLevel:
|
1191
|
-
marginSize:
|
1192
|
-
imageSettings:
|
1193
|
-
} =
|
1180
|
+
}(), Mt = L.forwardRef(
|
1181
|
+
function(t, e) {
|
1182
|
+
const i = t, {
|
1183
|
+
value: c,
|
1184
|
+
size: u = Ce,
|
1185
|
+
level: y = je,
|
1186
|
+
bgColor: x = Me,
|
1187
|
+
fgColor: r = Re,
|
1188
|
+
includeMargin: n = Se,
|
1189
|
+
minVersion: a = Le,
|
1190
|
+
boostLevel: l,
|
1191
|
+
marginSize: d,
|
1192
|
+
imageSettings: g
|
1193
|
+
} = i, m = ce(i, [
|
1194
1194
|
"value",
|
1195
1195
|
"size",
|
1196
1196
|
"level",
|
@@ -1201,92 +1201,92 @@ var Mt = function() {
|
|
1201
1201
|
"boostLevel",
|
1202
1202
|
"marginSize",
|
1203
1203
|
"imageSettings"
|
1204
|
-
]), { style:
|
1204
|
+
]), { style: f } = m, k = ce(m, ["style"]), w = g == null ? void 0 : g.src, p = L.useRef(null), T = L.useRef(null), C = L.useCallback(
|
1205
1205
|
(W) => {
|
1206
|
-
p.current = W, typeof
|
1206
|
+
p.current = W, typeof e == "function" ? e(W) : e && (e.current = W);
|
1207
1207
|
},
|
1208
|
-
[
|
1209
|
-
), [
|
1210
|
-
value:
|
1208
|
+
[e]
|
1209
|
+
), [q, H] = L.useState(!1), { margin: O, cells: M, numCells: v, calculatedImageSettings: S } = Ue({
|
1210
|
+
value: c,
|
1211
1211
|
level: y,
|
1212
|
-
minVersion:
|
1213
|
-
boostLevel:
|
1212
|
+
minVersion: a,
|
1213
|
+
boostLevel: l,
|
1214
1214
|
includeMargin: n,
|
1215
|
-
marginSize:
|
1216
|
-
imageSettings:
|
1217
|
-
size:
|
1215
|
+
marginSize: d,
|
1216
|
+
imageSettings: g,
|
1217
|
+
size: u
|
1218
1218
|
});
|
1219
|
-
|
1219
|
+
L.useEffect(() => {
|
1220
1220
|
if (p.current != null) {
|
1221
|
-
const W = p.current,
|
1222
|
-
if (!
|
1221
|
+
const W = p.current, I = W.getContext("2d");
|
1222
|
+
if (!I)
|
1223
1223
|
return;
|
1224
|
-
let
|
1225
|
-
const
|
1226
|
-
te &&
|
1227
|
-
|
1228
|
-
|
1224
|
+
let V = M;
|
1225
|
+
const $ = T.current, te = S != null && $ !== null && $.complete && $.naturalHeight !== 0 && $.naturalWidth !== 0;
|
1226
|
+
te && S.excavation != null && (V = De(
|
1227
|
+
M,
|
1228
|
+
S.excavation
|
1229
1229
|
));
|
1230
1230
|
const X = window.devicePixelRatio || 1;
|
1231
|
-
W.height = W.width =
|
1232
|
-
const G =
|
1233
|
-
|
1234
|
-
oe.forEach(function(ae,
|
1235
|
-
ae &&
|
1231
|
+
W.height = W.width = u * X;
|
1232
|
+
const G = u / v * X;
|
1233
|
+
I.scale(G, G), I.fillStyle = x, I.fillRect(0, 0, v, v), I.fillStyle = r, jt ? I.fill(new Path2D(Pe(V, O))) : M.forEach(function(oe, re) {
|
1234
|
+
oe.forEach(function(ae, P) {
|
1235
|
+
ae && I.fillRect(P + O, re + O, 1, 1);
|
1236
1236
|
});
|
1237
|
-
}),
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1237
|
+
}), S && (I.globalAlpha = S.opacity), te && I.drawImage(
|
1238
|
+
$,
|
1239
|
+
S.x + O,
|
1240
|
+
S.y + O,
|
1241
|
+
S.w,
|
1242
|
+
S.h
|
1243
1243
|
);
|
1244
1244
|
}
|
1245
|
-
}),
|
1246
|
-
|
1247
|
-
}, [
|
1248
|
-
const B =
|
1245
|
+
}), L.useEffect(() => {
|
1246
|
+
H(!1);
|
1247
|
+
}, [w]);
|
1248
|
+
const B = le({ height: u, width: u }, f);
|
1249
1249
|
let ee = null;
|
1250
|
-
return
|
1250
|
+
return w != null && (ee = /* @__PURE__ */ L.createElement(
|
1251
1251
|
"img",
|
1252
1252
|
{
|
1253
|
-
src:
|
1254
|
-
key:
|
1253
|
+
src: w,
|
1254
|
+
key: w,
|
1255
1255
|
style: { display: "none" },
|
1256
1256
|
onLoad: () => {
|
1257
|
-
|
1257
|
+
H(!0);
|
1258
1258
|
},
|
1259
|
-
ref:
|
1260
|
-
crossOrigin:
|
1259
|
+
ref: T,
|
1260
|
+
crossOrigin: S == null ? void 0 : S.crossOrigin
|
1261
1261
|
}
|
1262
|
-
)), /* @__PURE__ */
|
1262
|
+
)), /* @__PURE__ */ L.createElement(L.Fragment, null, /* @__PURE__ */ L.createElement(
|
1263
1263
|
"canvas",
|
1264
|
-
|
1264
|
+
le({
|
1265
1265
|
style: B,
|
1266
|
-
height:
|
1267
|
-
width:
|
1268
|
-
ref:
|
1266
|
+
height: u,
|
1267
|
+
width: u,
|
1268
|
+
ref: C,
|
1269
1269
|
role: "img"
|
1270
|
-
},
|
1270
|
+
}, k)
|
1271
1271
|
), ee);
|
1272
1272
|
}
|
1273
1273
|
);
|
1274
|
-
|
1275
|
-
var
|
1276
|
-
function(
|
1277
|
-
const
|
1278
|
-
value:
|
1279
|
-
size:
|
1280
|
-
level: y =
|
1281
|
-
bgColor:
|
1282
|
-
fgColor:
|
1283
|
-
includeMargin: n =
|
1284
|
-
minVersion:
|
1285
|
-
boostLevel:
|
1286
|
-
title:
|
1287
|
-
marginSize:
|
1288
|
-
imageSettings:
|
1289
|
-
} =
|
1274
|
+
Mt.displayName = "QRCodeCanvas";
|
1275
|
+
var Oe = L.forwardRef(
|
1276
|
+
function(t, e) {
|
1277
|
+
const i = t, {
|
1278
|
+
value: c,
|
1279
|
+
size: u = Ce,
|
1280
|
+
level: y = je,
|
1281
|
+
bgColor: x = Me,
|
1282
|
+
fgColor: r = Re,
|
1283
|
+
includeMargin: n = Se,
|
1284
|
+
minVersion: a = Le,
|
1285
|
+
boostLevel: l,
|
1286
|
+
title: d,
|
1287
|
+
marginSize: g,
|
1288
|
+
imageSettings: h
|
1289
|
+
} = i, m = ce(i, [
|
1290
1290
|
"value",
|
1291
1291
|
"size",
|
1292
1292
|
"level",
|
@@ -1298,91 +1298,142 @@ var Ie = S.forwardRef(
|
|
1298
1298
|
"title",
|
1299
1299
|
"marginSize",
|
1300
1300
|
"imageSettings"
|
1301
|
-
]), { margin:
|
1302
|
-
value:
|
1301
|
+
]), { margin: f, cells: k, numCells: w, calculatedImageSettings: p } = Ue({
|
1302
|
+
value: c,
|
1303
1303
|
level: y,
|
1304
|
-
minVersion:
|
1305
|
-
boostLevel:
|
1304
|
+
minVersion: a,
|
1305
|
+
boostLevel: l,
|
1306
1306
|
includeMargin: n,
|
1307
|
-
marginSize:
|
1308
|
-
imageSettings:
|
1309
|
-
size:
|
1307
|
+
marginSize: g,
|
1308
|
+
imageSettings: h,
|
1309
|
+
size: u
|
1310
1310
|
});
|
1311
|
-
let
|
1312
|
-
|
1313
|
-
|
1311
|
+
let T = k, C = null;
|
1312
|
+
h != null && p != null && (p.excavation != null && (T = De(
|
1313
|
+
k,
|
1314
1314
|
p.excavation
|
1315
|
-
)),
|
1315
|
+
)), C = /* @__PURE__ */ L.createElement(
|
1316
1316
|
"image",
|
1317
1317
|
{
|
1318
|
-
href:
|
1318
|
+
href: h.src,
|
1319
1319
|
height: p.h,
|
1320
1320
|
width: p.w,
|
1321
|
-
x: p.x +
|
1322
|
-
y: p.y +
|
1321
|
+
x: p.x + f,
|
1322
|
+
y: p.y + f,
|
1323
1323
|
preserveAspectRatio: "none",
|
1324
1324
|
opacity: p.opacity,
|
1325
1325
|
crossOrigin: p.crossOrigin
|
1326
1326
|
}
|
1327
1327
|
));
|
1328
|
-
const
|
1329
|
-
return /* @__PURE__ */
|
1328
|
+
const q = Pe(T, f);
|
1329
|
+
return /* @__PURE__ */ L.createElement(
|
1330
1330
|
"svg",
|
1331
|
-
|
1332
|
-
height:
|
1333
|
-
width:
|
1334
|
-
viewBox: `0 0 ${
|
1335
|
-
ref:
|
1331
|
+
le({
|
1332
|
+
height: u,
|
1333
|
+
width: u,
|
1334
|
+
viewBox: `0 0 ${w} ${w}`,
|
1335
|
+
ref: e,
|
1336
1336
|
role: "img"
|
1337
1337
|
}, m),
|
1338
|
-
!!
|
1339
|
-
/* @__PURE__ */
|
1338
|
+
!!d && /* @__PURE__ */ L.createElement("title", null, d),
|
1339
|
+
/* @__PURE__ */ L.createElement(
|
1340
1340
|
"path",
|
1341
1341
|
{
|
1342
|
-
fill:
|
1343
|
-
d: `M0,0 h${
|
1342
|
+
fill: x,
|
1343
|
+
d: `M0,0 h${w}v${w}H0z`,
|
1344
1344
|
shapeRendering: "crispEdges"
|
1345
1345
|
}
|
1346
1346
|
),
|
1347
|
-
/* @__PURE__ */
|
1348
|
-
|
1347
|
+
/* @__PURE__ */ L.createElement("path", { fill: r, d: q, shapeRendering: "crispEdges" }),
|
1348
|
+
C
|
1349
1349
|
);
|
1350
1350
|
}
|
1351
1351
|
);
|
1352
|
-
|
1353
|
-
const
|
1352
|
+
Oe.displayName = "QRCodeSVG";
|
1353
|
+
const Rt = ({
|
1354
1354
|
walletAddress: s,
|
1355
|
-
amount:
|
1356
|
-
currency:
|
1355
|
+
amount: t,
|
1356
|
+
currency: e,
|
1357
|
+
network: i,
|
1357
1358
|
theme: c = "light",
|
1358
1359
|
size: u = 200
|
1359
1360
|
}) => {
|
1360
|
-
const [
|
1361
|
+
const [y, x] = D(""), [r, n] = D(null);
|
1361
1362
|
Z(() => {
|
1362
|
-
if (!s) {
|
1363
|
-
|
1363
|
+
if (!s || s === "No address configured") {
|
1364
|
+
n("No wallet address configured for this network");
|
1364
1365
|
return;
|
1365
1366
|
}
|
1366
1367
|
try {
|
1367
|
-
let
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1368
|
+
let m;
|
1369
|
+
switch (i) {
|
1370
|
+
case "tron":
|
1371
|
+
e === "TRX" ? m = `tronlink://transfer?to=${s}&amount=${t}` : m = s;
|
1372
|
+
break;
|
1373
|
+
case "algorand":
|
1374
|
+
m = `algorand://${s}?amount=${Math.floor(parseFloat(t) * 1e6)}`;
|
1375
|
+
break;
|
1376
|
+
case "bsc":
|
1377
|
+
if (e === "BNB")
|
1378
|
+
m = `ethereum:${s}@56?value=${d(t)}`;
|
1379
|
+
else {
|
1380
|
+
const f = a(e, "bsc");
|
1381
|
+
f ? m = `ethereum:${f}/transfer?address=${s}&uint256=${l(t, e)}@56` : m = s;
|
1382
|
+
}
|
1383
|
+
break;
|
1384
|
+
case "ethereum":
|
1385
|
+
default:
|
1386
|
+
if (e === "ETH")
|
1387
|
+
m = `ethereum:${s}@1?value=${d(t)}`;
|
1388
|
+
else {
|
1389
|
+
const f = a(e, "ethereum");
|
1390
|
+
f ? m = `ethereum:${f}/transfer?address=${s}&uint256=${l(t, e)}` : m = s;
|
1391
|
+
}
|
1392
|
+
break;
|
1393
|
+
}
|
1394
|
+
x(m), n(null);
|
1395
|
+
} catch (m) {
|
1396
|
+
console.error("Error generating QR code:", m), n("Error generating payment QR code");
|
1397
|
+
}
|
1398
|
+
}, [s, t, e, i]);
|
1399
|
+
const a = (m, f) => {
|
1400
|
+
var w;
|
1401
|
+
return ((w = {
|
1402
|
+
ethereum: {
|
1403
|
+
USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
1404
|
+
USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
|
1405
|
+
},
|
1406
|
+
bsc: {
|
1407
|
+
USDT: "0x55d398326f99059fF775485246999027B3197955",
|
1408
|
+
USDC: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"
|
1409
|
+
},
|
1410
|
+
tron: {
|
1411
|
+
USDT: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
1412
|
+
USDC: "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8"
|
1413
|
+
}
|
1414
|
+
}[f]) == null ? void 0 : w[m]) || "";
|
1415
|
+
}, l = (m, f) => {
|
1416
|
+
const k = f === "USDT" || f === "USDC" ? 6 : 18;
|
1417
|
+
return Math.floor(parseFloat(m) * Math.pow(10, k)).toString();
|
1418
|
+
}, d = (m) => Math.floor(parseFloat(m) * 1e18).toString(), g = (m) => ({
|
1419
|
+
ethereum: "Ethereum",
|
1420
|
+
bsc: "BSC",
|
1421
|
+
tron: "Tron",
|
1422
|
+
algorand: "Algorand"
|
1423
|
+
})[m] || m, h = (m) => ({
|
1424
|
+
ethereum: ["MetaMask", "Trust Wallet", "Coinbase Wallet"],
|
1425
|
+
bsc: ["MetaMask", "Trust Wallet", "SafePal"],
|
1426
|
+
tron: ["TronLink", "Trust Wallet"],
|
1427
|
+
algorand: ["Pera Wallet", "MyAlgo Wallet"]
|
1428
|
+
})[m] || ["MetaMask", "Trust Wallet"];
|
1429
|
+
return /* @__PURE__ */ o.jsxs("div", { className: "flex flex-col items-center", children: [
|
1430
|
+
r ? /* @__PURE__ */ o.jsxs("div", { className: "p-4 rounded-lg bg-red-100 mb-3 text-red-700 text-center", children: [
|
1431
|
+
/* @__PURE__ */ o.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-8 w-8 mx-auto mb-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ o.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
|
1432
|
+
/* @__PURE__ */ o.jsx("p", { className: "font-medium", children: r })
|
1433
|
+
] }) : /* @__PURE__ */ o.jsx("div", { className: "p-4 rounded-lg bg-white mb-3 shadow-sm border", children: y && /* @__PURE__ */ o.jsx(
|
1434
|
+
Oe,
|
1384
1435
|
{
|
1385
|
-
value:
|
1436
|
+
value: y,
|
1386
1437
|
size: u,
|
1387
1438
|
bgColor: c === "dark" ? "#374151" : "#FFFFFF",
|
1388
1439
|
fgColor: c === "dark" ? "#FFFFFF" : "#000000",
|
@@ -1390,34 +1441,87 @@ const Vt = ({
|
|
1390
1441
|
includeMargin: !0
|
1391
1442
|
}
|
1392
1443
|
) }),
|
1393
|
-
/* @__PURE__ */
|
1394
|
-
/* @__PURE__ */
|
1395
|
-
|
1444
|
+
/* @__PURE__ */ o.jsxs("div", { className: "text-center text-sm text-gray-700 mb-4", children: [
|
1445
|
+
/* @__PURE__ */ o.jsxs("p", { className: "font-semibold text-gray-800 flex items-center justify-center", children: [
|
1446
|
+
/* @__PURE__ */ o.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-4 w-4 mr-1", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ o.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 4v1m6 11h2m-6 0h-2v4m0-11v3m0 0h.01M12 12h4.01M12 12h-4.01M12 12V8.01" }) }),
|
1447
|
+
"Scan to Pay with ",
|
1448
|
+
e
|
1449
|
+
] }),
|
1450
|
+
/* @__PURE__ */ o.jsxs("p", { className: "text-xs text-gray-500 mt-1", children: [
|
1451
|
+
"Scan with your ",
|
1452
|
+
g(i),
|
1453
|
+
" wallet app"
|
1454
|
+
] })
|
1396
1455
|
] }),
|
1397
|
-
/* @__PURE__ */
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
/* @__PURE__ */ a.jsx("li", { children: "1. Open your crypto wallet app (MetaMask, Trust Wallet, etc.)" }),
|
1402
|
-
/* @__PURE__ */ a.jsx("li", { children: "2. Scan the QR code above" }),
|
1403
|
-
/* @__PURE__ */ a.jsxs("li", { children: [
|
1404
|
-
"3. Confirm the payment amount (",
|
1405
|
-
r,
|
1406
|
-
" ",
|
1456
|
+
/* @__PURE__ */ o.jsxs("div", { className: "w-full mb-4 p-3 bg-gray-50 rounded-lg", children: [
|
1457
|
+
/* @__PURE__ */ o.jsxs("div", { className: "flex justify-between items-center", children: [
|
1458
|
+
/* @__PURE__ */ o.jsx("span", { className: "text-sm font-medium text-gray-700", children: "Amount to Pay:" }),
|
1459
|
+
/* @__PURE__ */ o.jsxs("span", { className: "text-lg font-bold text-[#7042D2]", children: [
|
1407
1460
|
t,
|
1461
|
+
" ",
|
1462
|
+
e
|
1463
|
+
] })
|
1464
|
+
] }),
|
1465
|
+
/* @__PURE__ */ o.jsxs("div", { className: "flex justify-between items-center mt-1", children: [
|
1466
|
+
/* @__PURE__ */ o.jsx("span", { className: "text-xs text-gray-500", children: "Network:" }),
|
1467
|
+
/* @__PURE__ */ o.jsx("span", { className: "text-xs font-medium text-gray-700", children: g(i) })
|
1468
|
+
] })
|
1469
|
+
] }),
|
1470
|
+
!r && /* @__PURE__ */ o.jsxs("div", { className: "w-full mb-4", children: [
|
1471
|
+
/* @__PURE__ */ o.jsx("p", { className: "text-xs text-gray-500 mb-1 text-center", children: "Or copy wallet address:" }),
|
1472
|
+
/* @__PURE__ */ o.jsx(
|
1473
|
+
"div",
|
1474
|
+
{
|
1475
|
+
className: "text-xs font-mono p-2 rounded bg-gray-100 text-gray-700 break-all text-center select-all cursor-pointer border",
|
1476
|
+
onClick: () => {
|
1477
|
+
var m;
|
1478
|
+
return (m = navigator.clipboard) == null ? void 0 : m.writeText(s);
|
1479
|
+
},
|
1480
|
+
title: "Click to copy",
|
1481
|
+
children: s
|
1482
|
+
}
|
1483
|
+
)
|
1484
|
+
] }),
|
1485
|
+
/* @__PURE__ */ o.jsx("div", { className: "w-full", children: /* @__PURE__ */ o.jsxs("div", { className: "p-3 rounded bg-blue-50 border border-blue-200", children: [
|
1486
|
+
/* @__PURE__ */ o.jsxs("h4", { className: "text-sm font-medium mb-2 text-blue-800 flex items-center", children: [
|
1487
|
+
/* @__PURE__ */ o.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-4 w-4 mr-1", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ o.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
|
1488
|
+
"Payment Instructions"
|
1489
|
+
] }),
|
1490
|
+
/* @__PURE__ */ o.jsxs("ol", { className: "text-xs space-y-1 text-blue-700", children: [
|
1491
|
+
/* @__PURE__ */ o.jsxs("li", { children: [
|
1492
|
+
"1. Open your crypto wallet app (",
|
1493
|
+
h(i).join(", "),
|
1408
1494
|
")"
|
1409
1495
|
] }),
|
1410
|
-
/* @__PURE__ */
|
1411
|
-
|
1496
|
+
/* @__PURE__ */ o.jsx("li", { children: "2. Scan the QR code above or copy the wallet address" }),
|
1497
|
+
/* @__PURE__ */ o.jsxs("li", { children: [
|
1498
|
+
"3. Send exactly ",
|
1499
|
+
/* @__PURE__ */ o.jsxs("strong", { children: [
|
1500
|
+
t,
|
1501
|
+
" ",
|
1502
|
+
e
|
1503
|
+
] }),
|
1504
|
+
" on ",
|
1505
|
+
g(i),
|
1506
|
+
" network"
|
1507
|
+
] }),
|
1508
|
+
/* @__PURE__ */ o.jsx("li", { children: '4. Click "I have sent the payment" button below after sending' })
|
1509
|
+
] }),
|
1510
|
+
/* @__PURE__ */ o.jsx("div", { className: "mt-3 p-2 bg-yellow-50 border border-yellow-200 rounded", children: /* @__PURE__ */ o.jsxs("p", { className: "text-xs text-yellow-800", children: [
|
1511
|
+
/* @__PURE__ */ o.jsx("strong", { children: "Important:" }),
|
1512
|
+
" Make sure you're sending on the correct network (",
|
1513
|
+
g(i),
|
1514
|
+
") and using the exact amount shown above."
|
1515
|
+
] }) })
|
1412
1516
|
] }) })
|
1413
1517
|
] });
|
1414
|
-
},
|
1415
|
-
const
|
1518
|
+
}, ie = ({ status: s, message: t, theme: e = "light" }) => {
|
1519
|
+
const i = () => {
|
1416
1520
|
switch (s) {
|
1417
1521
|
case "processing":
|
1418
|
-
return /* @__PURE__ */
|
1522
|
+
return /* @__PURE__ */ o.jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20" });
|
1419
1523
|
case "success":
|
1420
|
-
return /* @__PURE__ */
|
1524
|
+
return /* @__PURE__ */ o.jsx("div", { className: "rounded-full h-12 w-12 bg-green-100 flex items-center justify-center", children: /* @__PURE__ */ o.jsx(
|
1421
1525
|
"svg",
|
1422
1526
|
{
|
1423
1527
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -1426,11 +1530,11 @@ const Vt = ({
|
|
1426
1530
|
viewBox: "0 0 24 24",
|
1427
1531
|
stroke: "currentColor",
|
1428
1532
|
strokeWidth: 2,
|
1429
|
-
children: /* @__PURE__ */
|
1533
|
+
children: /* @__PURE__ */ o.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
|
1430
1534
|
}
|
1431
1535
|
) });
|
1432
1536
|
case "error":
|
1433
|
-
return /* @__PURE__ */
|
1537
|
+
return /* @__PURE__ */ o.jsx("div", { className: "rounded-full h-12 w-12 bg-red-100 flex items-center justify-center", children: /* @__PURE__ */ o.jsx(
|
1434
1538
|
"svg",
|
1435
1539
|
{
|
1436
1540
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -1439,13 +1543,13 @@ const Vt = ({
|
|
1439
1543
|
viewBox: "0 0 24 24",
|
1440
1544
|
stroke: "currentColor",
|
1441
1545
|
strokeWidth: 2,
|
1442
|
-
children: /* @__PURE__ */
|
1546
|
+
children: /* @__PURE__ */ o.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
1443
1547
|
}
|
1444
1548
|
) });
|
1445
1549
|
default:
|
1446
1550
|
return null;
|
1447
1551
|
}
|
1448
|
-
},
|
1552
|
+
}, c = () => {
|
1449
1553
|
switch (s) {
|
1450
1554
|
case "processing":
|
1451
1555
|
return "Processing Payment";
|
@@ -1456,374 +1560,499 @@ const Vt = ({
|
|
1456
1560
|
default:
|
1457
1561
|
return "Unknown Status";
|
1458
1562
|
}
|
1459
|
-
},
|
1563
|
+
}, u = () => {
|
1460
1564
|
switch (s) {
|
1461
1565
|
case "processing":
|
1462
|
-
return
|
1566
|
+
return e === "dark" ? "text-blue-300" : "text-blue-600";
|
1463
1567
|
case "success":
|
1464
|
-
return
|
1568
|
+
return e === "dark" ? "text-green-300" : "text-green-600";
|
1465
1569
|
case "error":
|
1466
|
-
return
|
1570
|
+
return e === "dark" ? "text-red-300" : "text-red-600";
|
1467
1571
|
default:
|
1468
|
-
return
|
1572
|
+
return e === "dark" ? "text-gray-300" : "text-gray-600";
|
1469
1573
|
}
|
1470
1574
|
};
|
1471
|
-
return /* @__PURE__ */
|
1472
|
-
/* @__PURE__ */
|
1473
|
-
/* @__PURE__ */
|
1474
|
-
/* @__PURE__ */
|
1475
|
-
s === "processing" && /* @__PURE__ */
|
1476
|
-
s === "success" && /* @__PURE__ */
|
1575
|
+
return /* @__PURE__ */ o.jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
|
1576
|
+
/* @__PURE__ */ o.jsx("div", { className: "mb-4", children: i() }),
|
1577
|
+
/* @__PURE__ */ o.jsx("h3", { className: `text-xl font-bold mb-2 ${e === "dark" ? "text-white" : "text-gray-900"}`, children: c() }),
|
1578
|
+
/* @__PURE__ */ o.jsx("p", { className: `text-center ${u()}`, children: t }),
|
1579
|
+
s === "processing" && /* @__PURE__ */ o.jsx("div", { className: `mt-4 text-xs ${e === "dark" ? "text-gray-400" : "text-gray-500"}`, children: "This may take a few moments. Please do not close this window." }),
|
1580
|
+
s === "success" && /* @__PURE__ */ o.jsx("div", { className: `mt-4 p-2 rounded ${e === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: /* @__PURE__ */ o.jsx("p", { className: `text-xs ${e === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Your payment has been successfully processed. You will receive a confirmation shortly." }) })
|
1477
1581
|
] });
|
1478
|
-
},
|
1479
|
-
const [u,
|
1582
|
+
}, St = ({ onSelect: s, selected: t, theme: e = "light", supportedNetworks: i = [] }) => {
|
1583
|
+
const [c, u] = D(b.ETHEREUM), [y, x] = D({}), [r, n] = D(!1);
|
1480
1584
|
Z(() => {
|
1481
|
-
|
1585
|
+
x(ue());
|
1482
1586
|
}, []);
|
1483
|
-
const
|
1587
|
+
const a = [
|
1484
1588
|
{
|
1485
|
-
id:
|
1486
|
-
name: "
|
1487
|
-
description: "
|
1488
|
-
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",
|
1489
|
-
networks: [A.ETHEREUM, A.BSC, A.TRON]
|
1589
|
+
id: b.ETHEREUM,
|
1590
|
+
name: "Ethereum",
|
1591
|
+
description: "ERC-20 tokens"
|
1490
1592
|
},
|
1491
1593
|
{
|
1492
|
-
id:
|
1493
|
-
name: "
|
1494
|
-
description: "
|
1495
|
-
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",
|
1496
|
-
networks: [A.ETHEREUM, A.BSC, A.TRON]
|
1594
|
+
id: b.BSC,
|
1595
|
+
name: "BSC (Binance Smart Chain)",
|
1596
|
+
description: "BEP-20 tokens"
|
1497
1597
|
},
|
1498
1598
|
{
|
1499
|
-
id:
|
1500
|
-
name: "
|
1501
|
-
description: "
|
1502
|
-
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",
|
1503
|
-
networks: [A.BSC]
|
1599
|
+
id: b.TRON,
|
1600
|
+
name: "Tron",
|
1601
|
+
description: "TRC-20 tokens"
|
1504
1602
|
},
|
1505
1603
|
{
|
1506
|
-
id:
|
1507
|
-
name: "
|
1508
|
-
description: "
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
{
|
1513
|
-
|
1514
|
-
|
1515
|
-
description: "Tron",
|
1516
|
-
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",
|
1517
|
-
networks: [A.TRON]
|
1518
|
-
},
|
1519
|
-
{
|
1520
|
-
id: "ALGO",
|
1521
|
-
name: "ALGO",
|
1522
|
-
description: "Algorand",
|
1523
|
-
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR0Yx1Vp8qPQI5XZoJuKfQS8bj_FNiMZGCHqA&s",
|
1524
|
-
networks: [A.ALGORAND]
|
1525
|
-
}
|
1526
|
-
], n = e.filter((d) => c.length === 0 ? !0 : d.networks.some((m) => c.includes(m))), o = (d) => {
|
1527
|
-
const m = e.find((g) => g.id === d);
|
1528
|
-
return m ? m.networks : [];
|
1529
|
-
}, i = (d) => ({
|
1530
|
-
[A.ETHEREUM]: "Ethereum",
|
1531
|
-
[A.BSC]: "BSC",
|
1532
|
-
[A.TRON]: "Tron",
|
1533
|
-
[A.ALGORAND]: "Algorand"
|
1534
|
-
})[d] || d, l = (d) => Ne(d).length > 0, f = (d, m) => {
|
1535
|
-
var g;
|
1536
|
-
w(m), s({
|
1537
|
-
currency: d,
|
1538
|
-
network: m,
|
1539
|
-
tokenConfig: (g = Xe[d]) == null ? void 0 : g[m]
|
1540
|
-
});
|
1541
|
-
};
|
1542
|
-
return /* @__PURE__ */ a.jsxs("div", { children: [
|
1543
|
-
/* @__PURE__ */ a.jsx("h3", { className: `text-lg font-medium mb-3 ${t === "dark" ? "text-white" : "text-gray-800"}`, children: "Select Payment Method" }),
|
1544
|
-
/* @__PURE__ */ a.jsx("div", { className: "space-y-3", children: n.map((d) => {
|
1545
|
-
const m = o(d.id), g = (r == null ? void 0 : r.currency) === d.id;
|
1546
|
-
return /* @__PURE__ */ a.jsxs("div", { className: "space-y-2", children: [
|
1547
|
-
/* @__PURE__ */ a.jsxs("div", { className: `flex items-center p-3 rounded-lg border-2 transition-colors ${g ? t === "dark" ? "bg-blue-900/30 border-[#7042D2]" : "bg-blue-50 border-[#7042D2]" : t === "dark" ? "bg-gray-700 border-gray-700" : "bg-white border-gray-200"}`, children: [
|
1548
|
-
/* @__PURE__ */ a.jsx("div", { className: "flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mr-3", children: /* @__PURE__ */ a.jsx("img", { src: d.logo, alt: d.name, className: "h-6 w-6" }) }),
|
1549
|
-
/* @__PURE__ */ a.jsxs("div", { className: "flex-1", children: [
|
1550
|
-
/* @__PURE__ */ a.jsx("h4", { className: `font-medium ${t === "dark" ? "text-white" : "text-gray-900"}`, children: d.name }),
|
1551
|
-
/* @__PURE__ */ a.jsx("p", { className: `text-sm ${t === "dark" ? "text-gray-300" : "text-gray-500"}`, children: d.description })
|
1552
|
-
] })
|
1553
|
-
] }),
|
1554
|
-
m.length > 1 && /* @__PURE__ */ a.jsxs("div", { className: "ml-4 space-y-2", children: [
|
1555
|
-
/* @__PURE__ */ a.jsx("p", { className: `text-sm font-medium ${t === "dark" ? "text-gray-300" : "text-gray-700"}`, children: "Select Network:" }),
|
1556
|
-
/* @__PURE__ */ a.jsx("div", { className: "grid grid-cols-2 gap-2", children: m.map((b) => {
|
1557
|
-
const v = g && (r == null ? void 0 : r.network) === b, p = l(b);
|
1558
|
-
return /* @__PURE__ */ a.jsx(
|
1559
|
-
"button",
|
1560
|
-
{
|
1561
|
-
onClick: () => f(d.id, b),
|
1562
|
-
disabled: !p,
|
1563
|
-
className: `p-2 rounded-md text-sm font-medium transition-colors ${v ? "bg-[#7042D2] text-white" : p ? t === "dark" ? "bg-gray-600 text-gray-200 hover:bg-gray-500" : "bg-gray-100 text-gray-700 hover:bg-gray-200" : t === "dark" ? "bg-gray-800 text-gray-500 cursor-not-allowed" : "bg-gray-50 text-gray-400 cursor-not-allowed"}`,
|
1564
|
-
children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-center space-x-1", children: [
|
1565
|
-
/* @__PURE__ */ a.jsx("span", { children: i(b) }),
|
1566
|
-
!p && /* @__PURE__ */ a.jsx("span", { className: "text-xs", children: "(No wallet)" })
|
1567
|
-
] })
|
1568
|
-
},
|
1569
|
-
b
|
1570
|
-
);
|
1571
|
-
}) })
|
1572
|
-
] }),
|
1573
|
-
m.length === 1 && /* @__PURE__ */ a.jsx("div", { className: "ml-4", children: /* @__PURE__ */ a.jsx(
|
1574
|
-
"button",
|
1604
|
+
id: b.ALGORAND,
|
1605
|
+
name: "Algorand",
|
1606
|
+
description: "ASA tokens"
|
1607
|
+
}
|
1608
|
+
], l = (w) => {
|
1609
|
+
const p = [];
|
1610
|
+
switch (w) {
|
1611
|
+
case b.ETHEREUM:
|
1612
|
+
p.push(
|
1575
1613
|
{
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
}
|
1596
|
-
)
|
1597
|
-
}
|
1598
|
-
)
|
1599
|
-
] })
|
1614
|
+
id: "USDT",
|
1615
|
+
name: "USDT",
|
1616
|
+
description: "Tether USD",
|
1617
|
+
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",
|
1618
|
+
network: b.ETHEREUM
|
1619
|
+
},
|
1620
|
+
{
|
1621
|
+
id: "USDC",
|
1622
|
+
name: "USDC",
|
1623
|
+
description: "USD Coin",
|
1624
|
+
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",
|
1625
|
+
network: b.ETHEREUM
|
1626
|
+
},
|
1627
|
+
{
|
1628
|
+
id: "ETH",
|
1629
|
+
name: "ETH",
|
1630
|
+
description: "Ethereum",
|
1631
|
+
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",
|
1632
|
+
network: b.ETHEREUM
|
1600
1633
|
}
|
1601
|
-
)
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1634
|
+
);
|
1635
|
+
break;
|
1636
|
+
case b.BSC:
|
1637
|
+
p.push(
|
1638
|
+
{
|
1639
|
+
id: "USDT",
|
1640
|
+
name: "USDT",
|
1641
|
+
description: "Tether USD",
|
1642
|
+
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",
|
1643
|
+
network: b.BSC
|
1644
|
+
},
|
1645
|
+
{
|
1646
|
+
id: "USDC",
|
1647
|
+
name: "USDC",
|
1648
|
+
description: "USD Coin",
|
1649
|
+
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",
|
1650
|
+
network: b.BSC
|
1651
|
+
},
|
1652
|
+
{
|
1653
|
+
id: "BNB",
|
1654
|
+
name: "BNB",
|
1655
|
+
description: "Binance Coin",
|
1656
|
+
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",
|
1657
|
+
network: b.BSC
|
1658
|
+
}
|
1659
|
+
);
|
1660
|
+
break;
|
1661
|
+
case b.TRON:
|
1662
|
+
p.push(
|
1663
|
+
{
|
1664
|
+
id: "USDT",
|
1665
|
+
name: "USDT",
|
1666
|
+
description: "Tether USD",
|
1667
|
+
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",
|
1668
|
+
network: b.TRON
|
1669
|
+
},
|
1670
|
+
{
|
1671
|
+
id: "USDC",
|
1672
|
+
name: "USDC",
|
1673
|
+
description: "USD Coin",
|
1674
|
+
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",
|
1675
|
+
network: b.TRON
|
1676
|
+
},
|
1677
|
+
{
|
1678
|
+
id: "TRX",
|
1679
|
+
name: "TRX",
|
1680
|
+
description: "Tron",
|
1681
|
+
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",
|
1682
|
+
network: b.TRON
|
1683
|
+
}
|
1684
|
+
);
|
1685
|
+
break;
|
1686
|
+
case b.ALGORAND:
|
1687
|
+
p.push(
|
1688
|
+
{
|
1689
|
+
id: "ALGO",
|
1690
|
+
name: "ALGO",
|
1691
|
+
description: "Algorand",
|
1692
|
+
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR0Yx1Vp8qPQI5XZoJuKfQS8bj_FNiMZGCHqA&s",
|
1693
|
+
network: b.ALGORAND
|
1694
|
+
}
|
1695
|
+
);
|
1696
|
+
break;
|
1697
|
+
}
|
1698
|
+
return p;
|
1699
|
+
}, d = (w) => {
|
1700
|
+
u(w), n(!1), (t == null ? void 0 : t.network) !== w && s(null);
|
1701
|
+
}, g = (w) => {
|
1702
|
+
var p;
|
1703
|
+
s({
|
1704
|
+
currency: w.id,
|
1705
|
+
network: c,
|
1706
|
+
tokenConfig: (p = Ye[w.id]) == null ? void 0 : p[c],
|
1707
|
+
method: w
|
1708
|
+
});
|
1709
|
+
}, h = l(c), m = r ? h : h.slice(0, 4);
|
1710
|
+
return /* @__PURE__ */ o.jsxs("div", { children: [
|
1711
|
+
/* @__PURE__ */ o.jsx("h3", { className: `text-lg font-medium mb-4 ${e === "dark" ? "text-white" : "text-gray-800"}`, children: "Select Payment Method" }),
|
1712
|
+
/* @__PURE__ */ o.jsxs("div", { className: "mb-6", children: [
|
1713
|
+
/* @__PURE__ */ o.jsx("label", { className: `block text-sm font-medium mb-2 ${e === "dark" ? "text-white" : "text-gray-700"}`, children: "Blockchain Network" }),
|
1714
|
+
/* @__PURE__ */ o.jsx(
|
1715
|
+
"select",
|
1716
|
+
{
|
1717
|
+
value: c,
|
1718
|
+
onChange: (w) => d(w.target.value),
|
1719
|
+
className: `w-full p-3 rounded-lg border transition-colors ${e === "dark" ? "bg-gray-700 border-gray-600 text-white focus:border-[#7042D2]" : "bg-white border-gray-300 text-gray-900 focus:border-[#7042D2]"} focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:ring-opacity-50`,
|
1720
|
+
children: a.filter((w) => i.length === 0 || i.includes(w.id)).map((w) => /* @__PURE__ */ o.jsxs("option", { value: w.id, children: [
|
1721
|
+
w.name,
|
1722
|
+
" - ",
|
1723
|
+
w.description
|
1724
|
+
] }, w.id))
|
1725
|
+
}
|
1726
|
+
)
|
1727
|
+
] }),
|
1728
|
+
/* @__PURE__ */ o.jsxs("div", { className: "mb-4", children: [
|
1729
|
+
/* @__PURE__ */ o.jsx("label", { className: `block text-sm font-medium mb-3 ${e === "dark" ? "text-white" : "text-gray-700"}`, children: "Choose Cryptocurrency" }),
|
1730
|
+
/* @__PURE__ */ o.jsx("div", { className: "grid grid-cols-2 gap-3 mb-4", children: m.map((w) => /* @__PURE__ */ o.jsx(
|
1731
|
+
"button",
|
1732
|
+
{
|
1733
|
+
onClick: () => g(w),
|
1734
|
+
className: `p-4 rounded-lg transition-all duration-200 border-2 ${(t == null ? void 0 : t.currency) === w.id && (t == null ? void 0 : t.network) === c ? e === "dark" ? "bg-blue-900/30 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50" : "bg-blue-50 border-[#7042D2] ring-2 ring-[#7042D2] ring-opacity-50" : e === "dark" ? "bg-gray-700 hover:bg-gray-600 border-gray-600 hover:border-gray-500" : "bg-white hover:bg-gray-50 border-gray-200 hover:border-gray-300"}`,
|
1735
|
+
children: /* @__PURE__ */ o.jsxs("div", { className: "flex flex-col items-center text-center", children: [
|
1736
|
+
/* @__PURE__ */ o.jsx("div", { className: "flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mb-2 shadow-sm", children: /* @__PURE__ */ o.jsx("img", { src: w.logo, alt: w.name, className: "h-6 w-6" }) }),
|
1737
|
+
/* @__PURE__ */ o.jsxs("div", { children: [
|
1738
|
+
/* @__PURE__ */ o.jsx("h4", { className: `font-medium text-sm ${e === "dark" ? "text-white" : "text-gray-900"}`, children: w.name }),
|
1739
|
+
/* @__PURE__ */ o.jsx("p", { className: `text-xs ${e === "dark" ? "text-gray-300" : "text-gray-500"}`, children: w.description })
|
1740
|
+
] }),
|
1741
|
+
(t == null ? void 0 : t.currency) === w.id && (t == null ? void 0 : t.network) === c && /* @__PURE__ */ o.jsx("div", { className: "mt-2", children: /* @__PURE__ */ o.jsx(
|
1742
|
+
"svg",
|
1743
|
+
{
|
1744
|
+
xmlns: "http://www.w3.org/2000/svg",
|
1745
|
+
className: "h-4 w-4 text-[#7042D2]",
|
1746
|
+
viewBox: "0 0 20 20",
|
1747
|
+
fill: "currentColor",
|
1748
|
+
children: /* @__PURE__ */ o.jsx(
|
1749
|
+
"path",
|
1750
|
+
{
|
1751
|
+
fillRule: "evenodd",
|
1752
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
|
1753
|
+
clipRule: "evenodd"
|
1754
|
+
}
|
1755
|
+
)
|
1756
|
+
}
|
1757
|
+
) })
|
1758
|
+
] })
|
1759
|
+
},
|
1760
|
+
`${w.id}-${w.network}`
|
1761
|
+
)) }),
|
1762
|
+
h.length > 4 && /* @__PURE__ */ o.jsx(
|
1763
|
+
"button",
|
1764
|
+
{
|
1765
|
+
onClick: () => n(!r),
|
1766
|
+
className: `w-full py-2 px-4 rounded-lg text-sm font-medium transition-colors ${e === "dark" ? "bg-gray-700 text-gray-300 hover:bg-gray-600" : "bg-gray-100 text-gray-600 hover:bg-gray-200"}`,
|
1767
|
+
children: r ? "Show Less" : `Show More (${h.length - 4} more)`
|
1768
|
+
}
|
1769
|
+
)
|
1770
|
+
] }),
|
1771
|
+
/* @__PURE__ */ o.jsx("div", { className: `p-3 rounded-lg text-sm ${e === "dark" ? "bg-gray-800 text-gray-300" : "bg-gray-50 text-gray-600"}`, children: /* @__PURE__ */ o.jsxs("div", { className: "flex items-center", children: [
|
1772
|
+
/* @__PURE__ */ o.jsx("div", { className: `w-2 h-2 rounded-full mr-2 ${y[f(c)] ? "bg-green-500" : "bg-red-500"}` }),
|
1773
|
+
/* @__PURE__ */ o.jsx("span", { className: "text-xs", children: k(c) })
|
1774
|
+
] }) })
|
1611
1775
|
] });
|
1612
|
-
|
1776
|
+
function f(w) {
|
1777
|
+
switch (w) {
|
1778
|
+
case b.ETHEREUM:
|
1779
|
+
case b.BSC:
|
1780
|
+
return "metamask";
|
1781
|
+
case b.TRON:
|
1782
|
+
return "tronlink";
|
1783
|
+
case b.ALGORAND:
|
1784
|
+
return "lute";
|
1785
|
+
default:
|
1786
|
+
return "metamask";
|
1787
|
+
}
|
1788
|
+
}
|
1789
|
+
function k(w) {
|
1790
|
+
const p = f(w), T = y[p], C = {
|
1791
|
+
metamask: "MetaMask",
|
1792
|
+
tronlink: "TronLink",
|
1793
|
+
lute: "Lute Wallet"
|
1794
|
+
};
|
1795
|
+
return T ? `${C[p]} detected - Ready to pay` : `${C[p]} required - Please install to continue`;
|
1796
|
+
}
|
1797
|
+
}, Lt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJQAAAAkCAYAAABv9hOhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAmVSURBVHgB7Vzdcdu4Fv5I+X2VCoK83pkb2xVc2ikgTgVWKog8twDJBexYrsBKBXYKWJtbQWRnZl+NrWC172txcQBQBA8B/kiKV87qm4FFgMAhAX48ODg4dISOGB4/XKsfObl9e+Y9n3wViHt3QHY5ud2fYId1caDSJyc/V+kMW4q4S2VFFurcCR0Oj+/H3kq9vSv1VyDDKX5s0Fh8VSlTifrcx/cByR046QRbjE6EQmnQok9aGzlQ+QRZluDHh1BJaWFNKsJApQvs0JlQc+e4jzgelqX1HNUczfHjQqCqkRLsUCWU0jL94buHE659LGQ5G51SfafAUcfZn572Sv63hKZL1u6lYeYpk9jBo6HieKysgmulbR6VAX7lEmuSHpLWkU5tIoVW+3q6cxEhdbOaqMcPF4gzNVVEI2VsJXi5oHE4d/JSpY/YwUOoRYkwA1qxWWPcIvtSlhDbc/FBWc5i+RbblR8ZsGaKzDIJPKV42Rir9EqlNzZJ7OCzoRZTlG0lTYalBlosbsr1o33zg4JQijBKm6V0WLgRtN1hm+DSaruXDq6x//XY4wX0oJWNo9R5VF61xL1rRY4jIsrw6F4iioQuz7JX5nz8Wh2bulGU0o+2kziZMqSTu7X9UwLGCBZOGWnEFOWXoQk0ZZ945FCS+D4QKN873W8Kv122Kv6Jfmns+QrJITl89+09cwH0LakOkS3OEPWuS42yrHiQiydjX8Q9IqVw6kjVdh1bI1FphPoV1RTGvpFryklVulTpJnD+jrX/aK9NeET5YR7Z+7lC+Jr0sD9gvQeeoF2/PjrXIfI9orxqpfEboxmkGFyn6yzsNnj664MiAH9rBLkKlJa6IU+4LsnyNyu7t7/n6rxUBvgAxj9jizWZSMNJdAd1lgjMH6IPA5gBGgXOX7SUk9hrbsK/JFpcM3eUruq47NIvd3xIEVyyOp/QDu9Z/nJJKL0K4ys6RYAlcZaItAdcabGh0kSHk3R/rIsXi4nO39p8FBU3paa5NclEA9V1oMeokoo0xBDdMLTt1oHZPWhGv0NdLr9rv8YoxmfiuY8E9aDzgpWle+RzUiu7T8pQpgq0V0dkmJmVGL6oPTu1zfJA+ZG2m3I7CZp0M+eYmF5otCyji821xlrPZqI378BTnqr0qz2mAXjv6eBYJdKcNG3R4A1q5Ejb/n+oDia128QemoTRBtLKy/fphFOH+jJEe4JcoNovaa+T2uuIwLXGMH1PbUqccyNbFgLfWpvq6yqyZA3p0U5f2tfU1iG5IcflAGavzE00LYia+o9O3T9smfDIoXpJQI5gcvLk1r9j5wbOOV/bKfz7fX0Ue4LufedIPPft3ie/zgThfUWqfx2Ql3hk1T1D3kc9g8T5iqwGQqWr4fG3Ea3w2i73N+QWGLG8RGHg+jCFMWzz4zf2NyQnDcgJXWeE1SBRaDkOKuMLFXqQr9EMfj8pjGab19yHa5ATBAwZUlTHI6Ql+QpSwi5eYmt8f0YjsvH/j39r08lNgVS0YGX0kJuIStPuIczAUd18t95F0yoQ8Hu/E6wWVdA0vr7l/Bs0Y8Dy5y3a+Izw3Ljm90lTpK+/3BhP84M9q0kGaoqa2s1dv/GrbKqf7/7zO54PguVTtF9Su6tTbn9JFMv7JqQobKscCcKuhDo5TZDoZownLD8PlPswD8iawthkOYly49ztb+7jcrEk8tIPZT3bqbV9DhS5hGKRUAa7uvhilnu+nxGcCPdYDYLlJbrhVyZDYDvQ9+TvsBqEc0zay51KScm4hDph1y5p15IfypBpj8hEKu29dhH04lOVPw1EHzwnNmGTESTWwyYWG5vA97qPCcpjnaCs9U5Z/dL0WfihlNFNEQYmGkAbY8bwyjLSFAO7n/ecg8kJtCn77aBj/Z9YXmI7sKkXjMuiY25L5VOcQHVKTd1MTJpHbbN8JaMb9ax/7jdTsvwJVsOM5QW69SVheYntAO8XEYH2VaMV0ismi9uIpJVye8rFFGw8YqV5RlYLNUBvqWzyrWhCCh4h2t7ZN0BhF8w8ctou/0cok2+Odgb2c0Bi9fFpQopyP/OVMp/uvvCG8TJqIATtMc8o+uD18Ojh7uzdt1b7PMMkGPXZFr6HRw+4ifxU5wrl/Sq+TKaBP22QQ+fHrKzr6u57w7cHJ9AMqtdEvnNPm8TJS3jGg/xQHz3OTao8VcpQOQkjaSIsFUPV9kyWZZNW/qg4O9DBebS1szpoq4O/heRVpvsRrG4Cs8oZO2V0TJ2eoDpVTeHfN6NrXKDqWpBo5+d5TnADOl/pDQL1875N7O9jTd0UPC6uer6CyM2QRsk3cL2BcTkWT+RgnKnzVxSqQnt6tv6Fyp8tZRzdf1VkVRolGk9u/7vqw6A3KbTjL+1vH367iAbk0NZLEF5W59OiQPgNJw+8+0Z2DV9JUQ8uL2+ToHzfEmWnJ72w1x55VC9f0vdR7Of1PfVCTtQxwubBITwxXCW3gUOmfpBMeTSmiXU6QRwnVtSJzke9q6Lu4oOdMsd6Fbka6G0KkVEgbGQTQdztkxThuG8a6ARhMlG7bZvuctB9+cZHwH5DCaOFEvjJdIQwuAbMMUMgINAfD8UD41yo6dHaRgNb0reSzK+aFvNwYU1QIpWJOliHVGNU96DqkML/Bk3RLf6b6h2hvWf9n8IY9XucPhARDxva+FwIhMtQg0rEJiNLGSZI7lyvDMsXhbG1LKLeMvTBTodH9vN0IhVWnP6mNg1gDOaEnc+N+DxsIwQJQ6qBlcOnAZJDRPyMeiJ9QflhSHbuJyazCVze3JE79ZRzpCj6RY7pBH6NRNe5QfvVqgxcy4uIF5hPzCO/JlG2k44pP36g8Ip+qYyM78yZyxdPr1w3g/5yJoqv9apSGfuTX95uYgoRzrHE6hAbkrNtcG3LOVZzhnLbboqaT8aqU17mnermS+KY6Yzv5QBP7LOoOB64WR2MRxGgWsvhakNed+mkbZCzbSACSVR9Vm3BXQWEz3UNqoSquhCmJtTXbg4vjXDQFDjLtZD+pUjPQtA+F0021eRu/40NKz7ADtuMkB8urWtU/Yzq9u1UaQ+pow0WTzdV77hDlGgZgmuQLdT8HBmi1Hjfl3HnO2wbEhT2qWDniAeNIdD+z6jqQlXcuHL6MMHFYpEuDfYo2sSUtsPzQiDs6CQySTQgRldkWU6UKf+KRROxOaR4h5cF0kzk+pm2qdydUJF2D8yXH3NyPP21tf9dbYdOkDAOU3JFtF6R76EraO9PrfJC39hZv5NidG835b085Eb3qi4G/A2inrQKnVgMFAAAAABJRU5ErkJggg==", Pt = ({
|
1613
1798
|
isOpen: s,
|
1614
|
-
onClose:
|
1615
|
-
payment:
|
1616
|
-
paymentStatus:
|
1617
|
-
selectedPaymentMethod:
|
1618
|
-
onPaymentMethodSelect:
|
1799
|
+
onClose: t,
|
1800
|
+
payment: e,
|
1801
|
+
paymentStatus: i,
|
1802
|
+
selectedPaymentMethod: c,
|
1803
|
+
onPaymentMethodSelect: u,
|
1619
1804
|
onPayment: y,
|
1620
|
-
onBack:
|
1621
|
-
error:
|
1805
|
+
onBack: x,
|
1806
|
+
error: r,
|
1622
1807
|
theme: n = "light",
|
1623
|
-
merchantName:
|
1624
|
-
transactionHash:
|
1625
|
-
walletConnection:
|
1626
|
-
onConnectWallet:
|
1627
|
-
testMode:
|
1808
|
+
merchantName: a,
|
1809
|
+
transactionHash: l,
|
1810
|
+
walletConnection: d,
|
1811
|
+
onConnectWallet: g,
|
1812
|
+
testMode: h = !1,
|
1628
1813
|
supportedNetworks: m = [],
|
1629
|
-
availableWallets:
|
1630
|
-
supportedWallets:
|
1631
|
-
step:
|
1814
|
+
availableWallets: f = {},
|
1815
|
+
supportedWallets: k = [],
|
1816
|
+
step: w = "select-currency"
|
1632
1817
|
}) => {
|
1633
|
-
const p = (
|
1818
|
+
const [p, T] = D("wallet"), C = (v) => parseFloat(v).toFixed(2), q = (v) => v ? v.length <= 14 ? v : `${v.slice(0, 8)}...${v.slice(-6)}` : "", H = (v) => ({
|
1634
1819
|
ethereum: "Ethereum",
|
1635
1820
|
bsc: "BSC",
|
1636
1821
|
tron: "Tron",
|
1637
1822
|
algorand: "Algorand"
|
1638
|
-
})[
|
1823
|
+
})[v] || v, O = (v) => ({
|
1639
1824
|
[N.METAMASK]: "MetaMask",
|
1640
1825
|
[N.TRONLINK]: "TronLink",
|
1641
1826
|
[N.TRUST_WALLET]: "Trust Wallet",
|
1642
1827
|
[N.LUTE]: "Lute Wallet"
|
1643
|
-
})[
|
1828
|
+
})[v] || v, M = (v) => ({
|
1644
1829
|
[N.METAMASK]: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",
|
1645
1830
|
[N.TRONLINK]: "https://www.tronlink.org/images/logo.png",
|
1646
1831
|
[N.TRUST_WALLET]: "https://trustwallet.com/assets/images/trust_logotype.svg",
|
1647
1832
|
[N.LUTE]: "https://lute.app/logo.png"
|
1648
|
-
})[
|
1649
|
-
return s ? /* @__PURE__ */
|
1650
|
-
/* @__PURE__ */
|
1651
|
-
/* @__PURE__ */
|
1652
|
-
/* @__PURE__ */
|
1833
|
+
})[v] || "";
|
1834
|
+
return s ? /* @__PURE__ */ o.jsx("div", { className: "fixed inset-0 z-50 overflow-y-auto bg-black/50", children: /* @__PURE__ */ o.jsx("div", { className: "flex min-h-screen items-center justify-center p-4", children: /* @__PURE__ */ o.jsxs("div", { className: "relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800", children: [
|
1835
|
+
/* @__PURE__ */ o.jsxs("div", { className: "flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl", children: [
|
1836
|
+
/* @__PURE__ */ o.jsx("div", { className: "flex items-center", children: /* @__PURE__ */ o.jsx("h2", { className: "text-xl font-bold text-gray-900", children: /* @__PURE__ */ o.jsx("img", { src: Lt, className: "w-32", alt: "Coinley Logo" }) }) }),
|
1837
|
+
/* @__PURE__ */ o.jsx(
|
1653
1838
|
"button",
|
1654
1839
|
{
|
1655
|
-
onClick:
|
1840
|
+
onClick: t,
|
1656
1841
|
className: "text-gray-500 hover:text-gray-700 focus:outline-none",
|
1657
|
-
children: /* @__PURE__ */
|
1842
|
+
children: /* @__PURE__ */ o.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ o.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
1658
1843
|
}
|
1659
1844
|
)
|
1660
1845
|
] }),
|
1661
|
-
/* @__PURE__ */
|
1662
|
-
|
1663
|
-
/* @__PURE__ */
|
1846
|
+
/* @__PURE__ */ o.jsxs("div", { className: "mb-6 bg-[#F1ECFB] p-3 rounded-xl", children: [
|
1847
|
+
e && /* @__PURE__ */ o.jsxs("div", { className: "mb-6 p-4 rounded-lg", children: [
|
1848
|
+
/* @__PURE__ */ o.jsxs("p", { className: "text-lg text-gray-800 font-semibold", children: [
|
1664
1849
|
"PAY: ",
|
1665
|
-
|
1850
|
+
a
|
1666
1851
|
] }),
|
1667
|
-
/* @__PURE__ */
|
1668
|
-
/* @__PURE__ */
|
1669
|
-
/* @__PURE__ */
|
1852
|
+
/* @__PURE__ */ o.jsxs("div", { className: "flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg", children: [
|
1853
|
+
/* @__PURE__ */ o.jsx("span", { className: "font-medium text-gray-700", children: "Amount:" }),
|
1854
|
+
/* @__PURE__ */ o.jsxs("span", { className: "font-bold text-xl text-[#7042D2]", children: [
|
1670
1855
|
"$",
|
1671
|
-
|
1856
|
+
C(e.totalAmount || e.amount)
|
1672
1857
|
] })
|
1673
1858
|
] }),
|
1674
|
-
/* @__PURE__ */
|
1859
|
+
/* @__PURE__ */ o.jsx("div", { className: "text-xs mt-1 text-right", children: /* @__PURE__ */ o.jsxs("span", { className: "text-gray-500", children: [
|
1675
1860
|
"Payment ID: ",
|
1676
|
-
|
1861
|
+
e.id ? e.id.slice(0, 8) : "",
|
1677
1862
|
"..."
|
1678
1863
|
] }) })
|
1679
1864
|
] }),
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
/* @__PURE__ */
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1865
|
+
w === "select-currency" && /* @__PURE__ */ o.jsxs("div", { children: [
|
1866
|
+
/* @__PURE__ */ o.jsx(
|
1867
|
+
St,
|
1868
|
+
{
|
1869
|
+
onSelect: u,
|
1870
|
+
selected: c,
|
1871
|
+
theme: n,
|
1872
|
+
supportedNetworks: m
|
1873
|
+
}
|
1874
|
+
),
|
1875
|
+
c && /* @__PURE__ */ o.jsx("div", { className: "mt-6", children: /* @__PURE__ */ o.jsxs(
|
1876
|
+
"button",
|
1877
|
+
{
|
1878
|
+
onClick: () => u(c),
|
1879
|
+
className: "w-full py-3 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-lg transition-colors",
|
1880
|
+
children: [
|
1881
|
+
"Proceed with ",
|
1882
|
+
c.currency,
|
1883
|
+
" on ",
|
1884
|
+
H(c.network)
|
1885
|
+
]
|
1886
|
+
}
|
1887
|
+
) })
|
1888
|
+
] }),
|
1889
|
+
w === "confirm" && c && e && /* @__PURE__ */ o.jsxs("div", { children: [
|
1890
|
+
/* @__PURE__ */ o.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-gray-100", children: [
|
1891
|
+
/* @__PURE__ */ o.jsx("h3", { className: "text-lg font-medium mb-2 text-gray-800", children: "Payment Details" }),
|
1892
|
+
/* @__PURE__ */ o.jsxs("div", { className: "space-y-2", children: [
|
1893
|
+
/* @__PURE__ */ o.jsxs("div", { className: "flex justify-between", children: [
|
1894
|
+
/* @__PURE__ */ o.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Currency:" }),
|
1895
|
+
/* @__PURE__ */ o.jsx("span", { className: "font-medium", children: c.currency })
|
1696
1896
|
] }),
|
1697
|
-
/* @__PURE__ */
|
1698
|
-
/* @__PURE__ */
|
1699
|
-
/* @__PURE__ */
|
1897
|
+
/* @__PURE__ */ o.jsxs("div", { className: "flex justify-between", children: [
|
1898
|
+
/* @__PURE__ */ o.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Network:" }),
|
1899
|
+
/* @__PURE__ */ o.jsx("span", { className: "font-medium", children: H(c.network) })
|
1700
1900
|
] }),
|
1701
|
-
/* @__PURE__ */
|
1702
|
-
/* @__PURE__ */
|
1703
|
-
/* @__PURE__ */
|
1901
|
+
/* @__PURE__ */ o.jsxs("div", { className: "flex justify-between", children: [
|
1902
|
+
/* @__PURE__ */ o.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Fee:" }),
|
1903
|
+
/* @__PURE__ */ o.jsx("span", { className: "font-medium", children: "1.75%" })
|
1704
1904
|
] })
|
1705
1905
|
] })
|
1706
1906
|
] }),
|
1707
|
-
|
1907
|
+
/* @__PURE__ */ o.jsx("div", { className: "mb-4", children: /* @__PURE__ */ o.jsxs("div", { className: "flex border-b border-gray-200", children: [
|
1908
|
+
/* @__PURE__ */ o.jsx(
|
1909
|
+
"button",
|
1910
|
+
{
|
1911
|
+
onClick: () => T("wallet"),
|
1912
|
+
className: `py-2 px-4 text-sm font-medium ${p === "wallet" ? "border-b-2 border-[#7042D2] text-[#7042D2]" : "text-gray-500 hover:text-gray-700"}`,
|
1913
|
+
children: "Connect Wallet"
|
1914
|
+
}
|
1915
|
+
),
|
1916
|
+
/* @__PURE__ */ o.jsx(
|
1917
|
+
"button",
|
1918
|
+
{
|
1919
|
+
onClick: () => T("qrcode"),
|
1920
|
+
className: `py-2 px-4 text-sm font-medium ${p === "qrcode" ? "border-b-2 border-[#7042D2] text-[#7042D2]" : "text-gray-500 hover:text-gray-700"}`,
|
1921
|
+
children: "QR Code"
|
1922
|
+
}
|
1923
|
+
)
|
1924
|
+
] }) }),
|
1925
|
+
h ? (
|
1708
1926
|
// Test mode payment option
|
1709
|
-
/* @__PURE__ */
|
1710
|
-
/* @__PURE__ */
|
1711
|
-
/* @__PURE__ */
|
1712
|
-
/* @__PURE__ */
|
1713
|
-
/* @__PURE__ */
|
1927
|
+
/* @__PURE__ */ o.jsx("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: /* @__PURE__ */ o.jsxs("div", { className: "flex items-center", children: [
|
1928
|
+
/* @__PURE__ */ o.jsx("div", { className: "bg-[#7042D2] rounded-full p-2 mr-3", children: /* @__PURE__ */ o.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6 text-white", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ o.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }) }),
|
1929
|
+
/* @__PURE__ */ o.jsxs("div", { children: [
|
1930
|
+
/* @__PURE__ */ o.jsx("h3", { className: "font-medium text-gray-800", children: "Test Mode Payment" }),
|
1931
|
+
/* @__PURE__ */ o.jsx("p", { className: "text-sm text-gray-600", children: 'Click "Pay Now" to simulate a successful payment' })
|
1714
1932
|
] })
|
1715
1933
|
] }) })
|
1934
|
+
) : p === "qrcode" ? (
|
1935
|
+
// QR Code payment option
|
1936
|
+
/* @__PURE__ */ o.jsx("div", { className: "mb-4", children: /* @__PURE__ */ o.jsx(
|
1937
|
+
Rt,
|
1938
|
+
{
|
1939
|
+
walletAddress: e.recipientWallet || "No address configured",
|
1940
|
+
amount: e.totalAmount || e.amount,
|
1941
|
+
currency: c.currency,
|
1942
|
+
network: c.network,
|
1943
|
+
theme: n
|
1944
|
+
}
|
1945
|
+
) })
|
1716
1946
|
) : (
|
1717
|
-
//
|
1718
|
-
/* @__PURE__ */
|
1719
|
-
/* @__PURE__ */
|
1720
|
-
|
1721
|
-
/* @__PURE__ */
|
1722
|
-
|
1723
|
-
/* @__PURE__ */
|
1724
|
-
/* @__PURE__ */ a.jsxs("p", { className: "text-sm text-gray-600", children: [
|
1947
|
+
// Wallet connection option
|
1948
|
+
/* @__PURE__ */ o.jsxs("div", { className: "space-y-3 mb-4", children: [
|
1949
|
+
k.length === 0 ? /* @__PURE__ */ o.jsx("div", { className: "p-4 rounded-lg bg-yellow-50", children: /* @__PURE__ */ o.jsxs("div", { className: "flex items-center", children: [
|
1950
|
+
/* @__PURE__ */ o.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6 text-yellow-500 mr-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ o.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
|
1951
|
+
/* @__PURE__ */ o.jsxs("div", { children: [
|
1952
|
+
/* @__PURE__ */ o.jsx("h3", { className: "font-medium text-gray-800", children: "No Compatible Wallets" }),
|
1953
|
+
/* @__PURE__ */ o.jsxs("p", { className: "text-sm text-gray-600", children: [
|
1725
1954
|
"No wallets detected for ",
|
1726
|
-
|
1955
|
+
H(c.network),
|
1727
1956
|
" network"
|
1728
1957
|
] })
|
1729
1958
|
] })
|
1730
|
-
] }) }) :
|
1731
|
-
/* @__PURE__ */
|
1732
|
-
/* @__PURE__ */
|
1959
|
+
] }) }) : k.map((v) => /* @__PURE__ */ o.jsx("div", { className: "p-4 rounded-lg bg-blue-50", children: /* @__PURE__ */ o.jsxs("div", { className: "flex items-center justify-between", children: [
|
1960
|
+
/* @__PURE__ */ o.jsxs("div", { className: "flex items-center", children: [
|
1961
|
+
/* @__PURE__ */ o.jsx(
|
1733
1962
|
"img",
|
1734
1963
|
{
|
1735
|
-
src:
|
1736
|
-
alt:
|
1737
|
-
className: "w-8 h-8 mr-
|
1738
|
-
onError: (
|
1739
|
-
|
1964
|
+
src: M(v),
|
1965
|
+
alt: O(v),
|
1966
|
+
className: "w-8 h-8 mr-3",
|
1967
|
+
onError: (S) => {
|
1968
|
+
S.target.style.display = "none";
|
1740
1969
|
}
|
1741
1970
|
}
|
1742
1971
|
),
|
1743
|
-
/* @__PURE__ */
|
1744
|
-
/* @__PURE__ */
|
1745
|
-
/* @__PURE__ */
|
1972
|
+
/* @__PURE__ */ o.jsxs("div", { children: [
|
1973
|
+
/* @__PURE__ */ o.jsx("h3", { className: "font-medium text-gray-800", children: O(v) }),
|
1974
|
+
/* @__PURE__ */ o.jsxs("p", { className: "text-sm text-gray-600", children: [
|
1746
1975
|
"Pay with ",
|
1747
|
-
|
1976
|
+
O(v)
|
1748
1977
|
] })
|
1749
1978
|
] })
|
1750
1979
|
] }),
|
1751
|
-
(
|
1752
|
-
/* @__PURE__ */
|
1753
|
-
/* @__PURE__ */
|
1754
|
-
] }) : /* @__PURE__ */
|
1980
|
+
(d == null ? void 0 : d.walletType) === v ? /* @__PURE__ */ o.jsxs("div", { className: "flex items-center space-x-2", children: [
|
1981
|
+
/* @__PURE__ */ o.jsx("div", { className: "w-2 h-2 bg-green-500 rounded-full" }),
|
1982
|
+
/* @__PURE__ */ o.jsx("span", { className: "text-sm text-green-600", children: "Connected" })
|
1983
|
+
] }) : /* @__PURE__ */ o.jsx(
|
1755
1984
|
"button",
|
1756
1985
|
{
|
1757
|
-
onClick: () =>
|
1758
|
-
className: "py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",
|
1986
|
+
onClick: () => g(v),
|
1987
|
+
className: "py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md text-sm",
|
1759
1988
|
children: "Connect"
|
1760
1989
|
}
|
1761
1990
|
)
|
1762
|
-
] }) },
|
1763
|
-
/* @__PURE__ */
|
1764
|
-
/* @__PURE__ */
|
1765
|
-
|
1991
|
+
] }) }, v)),
|
1992
|
+
/* @__PURE__ */ o.jsx("div", { className: "space-y-2", children: Object.entries(f).filter(([v, S]) => !S).map(([v]) => /* @__PURE__ */ o.jsx("div", { className: "p-3 rounded-lg bg-gray-50", children: /* @__PURE__ */ o.jsxs("div", { className: "flex items-center justify-between", children: [
|
1993
|
+
/* @__PURE__ */ o.jsxs("span", { className: "text-sm text-gray-600", children: [
|
1994
|
+
O(v),
|
1766
1995
|
" not detected"
|
1767
1996
|
] }),
|
1768
|
-
/* @__PURE__ */
|
1997
|
+
/* @__PURE__ */ o.jsx(
|
1769
1998
|
"a",
|
1770
1999
|
{
|
1771
|
-
href: ct(
|
2000
|
+
href: ct(v),
|
1772
2001
|
target: "_blank",
|
1773
2002
|
rel: "noopener noreferrer",
|
1774
2003
|
className: "text-sm text-[#7042D2] hover:underline",
|
1775
2004
|
children: "Install"
|
1776
2005
|
}
|
1777
2006
|
)
|
1778
|
-
] }) },
|
2007
|
+
] }) }, v)) })
|
1779
2008
|
] })
|
1780
2009
|
),
|
1781
|
-
/* @__PURE__ */
|
1782
|
-
/* @__PURE__ */
|
2010
|
+
/* @__PURE__ */ o.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
|
2011
|
+
/* @__PURE__ */ o.jsx(
|
1783
2012
|
"button",
|
1784
2013
|
{
|
1785
2014
|
type: "button",
|
1786
|
-
onClick:
|
2015
|
+
onClick: x,
|
1787
2016
|
className: "w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",
|
1788
2017
|
children: "Back"
|
1789
2018
|
}
|
1790
2019
|
),
|
1791
|
-
/* @__PURE__ */
|
2020
|
+
/* @__PURE__ */ o.jsx(
|
1792
2021
|
"button",
|
1793
2022
|
{
|
1794
2023
|
type: "button",
|
1795
|
-
onClick: y,
|
2024
|
+
onClick: () => y(p === "qrcode"),
|
1796
2025
|
className: "w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",
|
1797
|
-
disabled: !
|
1798
|
-
children: "Pay Now"
|
2026
|
+
disabled: !h && p === "wallet" && !d,
|
2027
|
+
children: p === "qrcode" ? "I have sent the payment" : "Pay Now"
|
1799
2028
|
}
|
1800
2029
|
)
|
1801
2030
|
] })
|
1802
2031
|
] }),
|
1803
|
-
|
1804
|
-
|
2032
|
+
w === "processing" && /* @__PURE__ */ o.jsx(
|
2033
|
+
ie,
|
1805
2034
|
{
|
1806
2035
|
status: "processing",
|
1807
2036
|
theme: n,
|
1808
2037
|
message: "Processing your payment..."
|
1809
2038
|
}
|
1810
2039
|
),
|
1811
|
-
|
1812
|
-
/* @__PURE__ */
|
1813
|
-
|
2040
|
+
w === "success" && /* @__PURE__ */ o.jsxs("div", { children: [
|
2041
|
+
/* @__PURE__ */ o.jsx(
|
2042
|
+
ie,
|
1814
2043
|
{
|
1815
2044
|
status: "success",
|
1816
2045
|
theme: n,
|
1817
2046
|
message: "Payment successful!"
|
1818
2047
|
}
|
1819
2048
|
),
|
1820
|
-
|
1821
|
-
/* @__PURE__ */
|
1822
|
-
/* @__PURE__ */
|
1823
|
-
|
2049
|
+
l && /* @__PURE__ */ o.jsxs("div", { className: "mt-4 p-3 rounded-lg bg-gray-100", children: [
|
2050
|
+
/* @__PURE__ */ o.jsx("p", { className: "text-xs text-gray-600 mb-1", children: "Transaction Hash:" }),
|
2051
|
+
/* @__PURE__ */ o.jsx("p", { className: "text-sm font-mono break-all text-gray-800", children: q(l) }),
|
2052
|
+
c && /* @__PURE__ */ o.jsx(
|
1824
2053
|
"a",
|
1825
2054
|
{
|
1826
|
-
href: `${
|
2055
|
+
href: `${Dt(c.network)}/${Ut(c.network)}/${l}`,
|
1827
2056
|
target: "_blank",
|
1828
2057
|
rel: "noopener noreferrer",
|
1829
2058
|
className: "text-xs text-[#7042D2] mt-2 inline-block",
|
@@ -1832,220 +2061,225 @@ const Vt = ({
|
|
1832
2061
|
)
|
1833
2062
|
] })
|
1834
2063
|
] }),
|
1835
|
-
|
1836
|
-
/* @__PURE__ */
|
1837
|
-
|
2064
|
+
w === "error" && /* @__PURE__ */ o.jsxs("div", { children: [
|
2065
|
+
/* @__PURE__ */ o.jsx(
|
2066
|
+
ie,
|
1838
2067
|
{
|
1839
2068
|
status: "error",
|
1840
2069
|
theme: n,
|
1841
|
-
message:
|
2070
|
+
message: r || "An error occurred while processing your payment."
|
1842
2071
|
}
|
1843
2072
|
),
|
1844
|
-
/* @__PURE__ */
|
2073
|
+
/* @__PURE__ */ o.jsx(
|
1845
2074
|
"button",
|
1846
2075
|
{
|
1847
2076
|
type: "button",
|
1848
|
-
onClick:
|
2077
|
+
onClick: x,
|
1849
2078
|
className: "mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",
|
1850
2079
|
children: "Try Again"
|
1851
2080
|
}
|
1852
2081
|
)
|
1853
2082
|
] })
|
1854
2083
|
] }),
|
1855
|
-
/* @__PURE__ */
|
2084
|
+
/* @__PURE__ */ o.jsx("div", { className: "text-center text-xs text-gray-500", children: /* @__PURE__ */ o.jsxs("p", { children: [
|
1856
2085
|
"Powered by ",
|
1857
|
-
/* @__PURE__ */
|
2086
|
+
/* @__PURE__ */ o.jsx("span", { className: "text-[#7042D2]", children: "Coinley" }),
|
1858
2087
|
" - Secure Cryptocurrency Payments"
|
1859
2088
|
] }) })
|
1860
2089
|
] }) }) }) : null;
|
1861
|
-
},
|
2090
|
+
}, Dt = (s) => ({
|
1862
2091
|
ethereum: "https://etherscan.io",
|
1863
2092
|
bsc: "https://bscscan.com",
|
1864
2093
|
tron: "https://tronscan.org",
|
1865
2094
|
algorand: "https://algoexplorer.io"
|
1866
|
-
})[s] || "https://etherscan.io",
|
2095
|
+
})[s] || "https://etherscan.io", Ut = (s) => ({
|
2096
|
+
ethereum: "tx",
|
2097
|
+
bsc: "tx",
|
2098
|
+
tron: "transaction",
|
2099
|
+
algorand: "tx"
|
2100
|
+
})[s] || "tx", Ot = _e(({
|
1867
2101
|
apiKey: s,
|
1868
|
-
apiSecret:
|
1869
|
-
apiUrl:
|
1870
|
-
customerEmail:
|
1871
|
-
merchantName:
|
1872
|
-
merchantWalletAddresses:
|
2102
|
+
apiSecret: t,
|
2103
|
+
apiUrl: e,
|
2104
|
+
customerEmail: i,
|
2105
|
+
merchantName: c = "Merchant",
|
2106
|
+
merchantWalletAddresses: u = {},
|
1873
2107
|
// Object with network-specific addresses
|
1874
2108
|
onSuccess: y,
|
1875
|
-
onError:
|
1876
|
-
onClose:
|
2109
|
+
onError: x,
|
2110
|
+
onClose: r,
|
1877
2111
|
theme: n,
|
1878
|
-
autoOpen:
|
1879
|
-
debug:
|
1880
|
-
testMode:
|
1881
|
-
supportedNetworks:
|
2112
|
+
autoOpen: a = !1,
|
2113
|
+
debug: l = !1,
|
2114
|
+
testMode: d = !1,
|
2115
|
+
supportedNetworks: g = [],
|
1882
2116
|
// Array of supported networks
|
1883
|
-
preferredNetwork:
|
2117
|
+
preferredNetwork: h = b.ETHEREUM,
|
1884
2118
|
preferredWallet: m = N.METAMASK
|
1885
|
-
},
|
1886
|
-
const
|
1887
|
-
s || (
|
1888
|
-
const oe = n ||
|
1889
|
-
Je(
|
1890
|
-
open: (
|
1891
|
-
|
2119
|
+
}, f) => {
|
2120
|
+
const k = bt(), { theme: w } = yt(), [p, T] = D(a), [C, q] = D(null), [H, O] = D("idle"), [M, v] = D(null), [S, B] = D(null), [ee, W] = D(null), [I, V] = D(null), [$, te] = D({}), [X, G] = D("select-currency");
|
2121
|
+
s || (k == null || k.apiKey), t || (k == null || k.apiSecret), e || (k == null || k.apiUrl);
|
2122
|
+
const oe = n || w, re = l || (k == null ? void 0 : k.debug), ae = g.length > 0 ? g : [b.ETHEREUM, b.BSC, b.TRON, b.ALGORAND];
|
2123
|
+
Je(f, () => ({
|
2124
|
+
open: (A) => {
|
2125
|
+
Ie(A);
|
1892
2126
|
},
|
1893
2127
|
close: () => {
|
1894
2128
|
he();
|
1895
2129
|
},
|
1896
|
-
getPayment: () =>
|
1897
|
-
getWalletConnection: () =>
|
2130
|
+
getPayment: () => C,
|
2131
|
+
getWalletConnection: () => I
|
1898
2132
|
}));
|
1899
|
-
const
|
1900
|
-
re && console.log(`[Coinley SDK] ${
|
2133
|
+
const P = (A, F) => {
|
2134
|
+
re && console.log(`[Coinley SDK] ${A}`, F);
|
1901
2135
|
};
|
1902
2136
|
Z(() => {
|
1903
2137
|
if (typeof window != "undefined") {
|
1904
|
-
const
|
1905
|
-
te(
|
2138
|
+
const A = ue();
|
2139
|
+
te(A), P("Available wallets detected:", A);
|
1906
2140
|
}
|
1907
2141
|
}, [re]);
|
1908
|
-
const
|
1909
|
-
if (!
|
1910
|
-
B("Payment amount is required"),
|
2142
|
+
const Ie = (A) => R(void 0, null, function* () {
|
2143
|
+
if (!A || !A.amount) {
|
2144
|
+
B("Payment amount is required"), x && x(new Error("Payment amount is required"));
|
1911
2145
|
return;
|
1912
2146
|
}
|
1913
|
-
|
2147
|
+
O("loading"), T(!0), G("select-currency");
|
1914
2148
|
try {
|
1915
|
-
|
1916
|
-
const
|
1917
|
-
amount:
|
1918
|
-
currency:
|
1919
|
-
network:
|
1920
|
-
customerEmail:
|
1921
|
-
callbackUrl:
|
1922
|
-
metadata:
|
1923
|
-
merchantWalletAddresses: z(z({},
|
2149
|
+
P("Creating payment with details:", A);
|
2150
|
+
const F = yield ut({
|
2151
|
+
amount: A.amount,
|
2152
|
+
currency: A.currency || "USDT",
|
2153
|
+
network: A.network || h,
|
2154
|
+
customerEmail: A.customerEmail || i,
|
2155
|
+
callbackUrl: A.callbackUrl,
|
2156
|
+
metadata: A.metadata || {},
|
2157
|
+
merchantWalletAddresses: z(z({}, u), A.merchantWalletAddresses)
|
1924
2158
|
});
|
1925
|
-
|
1926
|
-
} catch (
|
1927
|
-
|
2159
|
+
P("Payment created:", F), q(F.payment), O("idle"), B(null), P("Payment created and state updated");
|
2160
|
+
} catch (F) {
|
2161
|
+
P("Error creating payment:", F), B(F.message || "Failed to create payment"), O("error"), x && x(F);
|
1928
2162
|
}
|
1929
2163
|
}), he = () => {
|
1930
|
-
|
1931
|
-
},
|
1932
|
-
|
1933
|
-
},
|
1934
|
-
X === "confirm" && (G("select-currency"),
|
1935
|
-
},
|
1936
|
-
if (!
|
2164
|
+
T(!1), W(null), V(null), v(null), G("select-currency"), r && r();
|
2165
|
+
}, Fe = (A) => {
|
2166
|
+
P("Payment method selected:", A), v(A), G("confirm");
|
2167
|
+
}, Be = () => {
|
2168
|
+
X === "confirm" && (G("select-currency"), V(null));
|
2169
|
+
}, We = (A) => R(void 0, null, function* () {
|
2170
|
+
if (!M) {
|
1937
2171
|
B("Please select a payment method first");
|
1938
2172
|
return;
|
1939
2173
|
}
|
1940
2174
|
try {
|
1941
|
-
|
1942
|
-
const
|
1943
|
-
|
1944
|
-
} catch (
|
1945
|
-
|
1946
|
-
}
|
1947
|
-
}),
|
1948
|
-
var
|
1949
|
-
if (!
|
2175
|
+
P("Connecting wallet:", { walletType: A, network: M.network });
|
2176
|
+
const F = yield et(A, M.network);
|
2177
|
+
V(F), B(null), P("Wallet connected successfully:", F);
|
2178
|
+
} catch (F) {
|
2179
|
+
P("Wallet connection error:", F), B(F.message || "Failed to connect wallet");
|
2180
|
+
}
|
2181
|
+
}), Qe = () => R(void 0, null, function* () {
|
2182
|
+
var A, F;
|
2183
|
+
if (!C || !M) {
|
1950
2184
|
B("Missing payment information");
|
1951
2185
|
return;
|
1952
2186
|
}
|
1953
|
-
if (!
|
2187
|
+
if (!I && !d) {
|
1954
2188
|
B("Please connect your wallet first");
|
1955
2189
|
return;
|
1956
2190
|
}
|
1957
|
-
|
2191
|
+
P("Starting payment process..."), O("loading"), W(null);
|
1958
2192
|
try {
|
1959
2193
|
let Q;
|
1960
|
-
if (
|
1961
|
-
|
2194
|
+
if (d)
|
2195
|
+
P("Test mode: Generating mock transaction..."), Q = `test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2, 10)}`;
|
1962
2196
|
else {
|
1963
|
-
const me =
|
2197
|
+
const me = u[M.network];
|
1964
2198
|
if (!me)
|
1965
|
-
throw new Error(`No merchant wallet address configured for ${
|
1966
|
-
|
2199
|
+
throw new Error(`No merchant wallet address configured for ${M.network}`);
|
2200
|
+
P("Sending transaction through wallet..."), Q = yield ot(I, {
|
1967
2201
|
to: me,
|
1968
|
-
amount:
|
1969
|
-
tokenAddress: (
|
1970
|
-
tokenDecimals: (
|
2202
|
+
amount: C.amount,
|
2203
|
+
tokenAddress: (A = M.tokenConfig) == null ? void 0 : A.address,
|
2204
|
+
tokenDecimals: (F = M.tokenConfig) == null ? void 0 : F.decimals
|
1971
2205
|
});
|
1972
2206
|
}
|
1973
|
-
|
1974
|
-
const
|
1975
|
-
paymentId:
|
2207
|
+
P("Transaction hash:", Q), W(Q), P("Processing payment with backend...");
|
2208
|
+
const Ge = yield ht({
|
2209
|
+
paymentId: C.id,
|
1976
2210
|
transactionHash: Q,
|
1977
|
-
network:
|
1978
|
-
currency:
|
1979
|
-
senderAddress:
|
2211
|
+
network: M.network,
|
2212
|
+
currency: M.currency,
|
2213
|
+
senderAddress: I == null ? void 0 : I.address
|
1980
2214
|
});
|
1981
|
-
|
1982
|
-
network:
|
1983
|
-
currency:
|
1984
|
-
amount:
|
2215
|
+
P("Payment processed successfully:", Ge), O("success"), G("success"), y && (P("Calling onSuccess callback..."), y(C.id, Q, {
|
2216
|
+
network: M.network,
|
2217
|
+
currency: M.currency,
|
2218
|
+
amount: C.amount
|
1985
2219
|
}));
|
1986
2220
|
} catch (Q) {
|
1987
|
-
|
2221
|
+
P("Payment error:", Q), B(Q.message || "Failed to process payment"), O("error"), G("error"), x && x(Q);
|
1988
2222
|
}
|
1989
|
-
}),
|
1990
|
-
return /* @__PURE__ */
|
1991
|
-
|
2223
|
+
}), ze = () => M ? Ze(M.network) : [];
|
2224
|
+
return /* @__PURE__ */ o.jsx(o.Fragment, { children: p && /* @__PURE__ */ o.jsx(
|
2225
|
+
Pt,
|
1992
2226
|
{
|
1993
2227
|
isOpen: p,
|
1994
2228
|
onClose: he,
|
1995
|
-
payment:
|
1996
|
-
paymentStatus:
|
1997
|
-
selectedPaymentMethod:
|
1998
|
-
onPaymentMethodSelect:
|
1999
|
-
onPayment:
|
2000
|
-
onBack:
|
2001
|
-
error:
|
2229
|
+
payment: C,
|
2230
|
+
paymentStatus: H,
|
2231
|
+
selectedPaymentMethod: M,
|
2232
|
+
onPaymentMethodSelect: Fe,
|
2233
|
+
onPayment: Qe,
|
2234
|
+
onBack: Be,
|
2235
|
+
error: S,
|
2002
2236
|
theme: oe,
|
2003
|
-
merchantName:
|
2237
|
+
merchantName: c,
|
2004
2238
|
transactionHash: ee,
|
2005
|
-
walletConnection:
|
2006
|
-
onConnectWallet:
|
2007
|
-
testMode:
|
2239
|
+
walletConnection: I,
|
2240
|
+
onConnectWallet: We,
|
2241
|
+
testMode: d,
|
2008
2242
|
supportedNetworks: ae,
|
2009
|
-
availableWallets:
|
2010
|
-
supportedWallets:
|
2243
|
+
availableWallets: $,
|
2244
|
+
supportedWallets: ze(),
|
2011
2245
|
step: X
|
2012
2246
|
}
|
2013
2247
|
) });
|
2014
2248
|
});
|
2015
2249
|
Ot.displayName = "CoinleyCheckout";
|
2016
|
-
const
|
2250
|
+
const Vt = {
|
2017
2251
|
apiUrl: "http://localhost:9000",
|
2018
2252
|
debug: !1,
|
2019
2253
|
testMode: !1,
|
2020
2254
|
theme: "light",
|
2021
2255
|
supportedNetworks: ["ethereum", "bsc", "tron", "algorand"]
|
2022
|
-
},
|
2256
|
+
}, _t = "0.3.2";
|
2023
2257
|
export {
|
2024
2258
|
Ot as CoinleyCheckout,
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2259
|
+
Pt as CoinleyModal,
|
2260
|
+
Ht as CoinleyProvider,
|
2261
|
+
Vt as DEFAULT_CONFIG,
|
2028
2262
|
de as NETWORK_CONFIG,
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2263
|
+
b as NETWORK_TYPES,
|
2264
|
+
St as PaymentMethods,
|
2265
|
+
ie as PaymentStatus,
|
2266
|
+
Rt as QRCode,
|
2267
|
+
Ye as TOKEN_CONFIG,
|
2268
|
+
qt as ThemeProvider,
|
2269
|
+
_t as VERSION,
|
2036
2270
|
N as WALLET_TYPES,
|
2037
2271
|
et as connectWallet,
|
2038
2272
|
ut as createPayment,
|
2039
2273
|
ue as detectWallets,
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2274
|
+
Gt as generateMockTransactionHash,
|
2275
|
+
Qt as getMerchantProfile,
|
2276
|
+
Bt as getPayment,
|
2277
|
+
Wt as getSupportedNetworks,
|
2278
|
+
Ze as getSupportedWalletsForNetwork,
|
2045
2279
|
ct as getWalletInstallUrl,
|
2046
2280
|
ht as processPayment,
|
2047
2281
|
ot as sendTransaction,
|
2048
|
-
|
2049
|
-
|
2282
|
+
bt as useCoinley,
|
2283
|
+
zt as validateWalletAddress
|
2050
2284
|
};
|
2051
2285
|
//# sourceMappingURL=coinley-checkout.es.js.map
|