coinley-checkout 0.3.0 → 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.
- package/dist/coinley-checkout.es.js +1662 -1949
- package/dist/coinley-checkout.es.js.map +1 -1
- package/dist/coinley-checkout.umd.js +4 -27
- package/dist/coinley-checkout.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +19 -13
@@ -1,111 +1,441 @@
|
|
1
|
-
var
|
2
|
-
var
|
3
|
-
var
|
4
|
-
var
|
5
|
-
var
|
6
|
-
for (var
|
7
|
-
|
8
|
-
if (
|
9
|
-
for (var
|
10
|
-
|
11
|
-
return
|
12
|
-
},
|
13
|
-
var
|
14
|
-
var
|
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
|
+
return s;
|
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
|
-
|
17
|
-
} catch (
|
18
|
-
|
16
|
+
x(e.next(r));
|
17
|
+
} catch (n) {
|
18
|
+
c(n);
|
19
19
|
}
|
20
|
-
},
|
20
|
+
}, y = (r) => {
|
21
21
|
try {
|
22
|
-
|
23
|
-
} catch (
|
24
|
-
|
22
|
+
x(e.throw(r));
|
23
|
+
} catch (n) {
|
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
|
-
|
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
|
+
ETHEREUM: "ethereum",
|
32
|
+
BSC: "bsc",
|
33
|
+
TRON: "tron",
|
34
|
+
ALGORAND: "algorand"
|
35
|
+
}, N = {
|
36
|
+
METAMASK: "metamask",
|
37
|
+
TRONLINK: "tronlink",
|
38
|
+
TRUST_WALLET: "trust_wallet",
|
39
|
+
LUTE: "lute"
|
40
|
+
}, de = {
|
41
|
+
[b.ETHEREUM]: {
|
42
|
+
chainId: "0x1",
|
43
|
+
chainName: "Ethereum Mainnet",
|
44
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
45
|
+
rpcUrls: ["https://mainnet.infura.io/v3/"],
|
46
|
+
blockExplorerUrls: ["https://etherscan.io/"],
|
47
|
+
supportedWallets: [N.METAMASK, N.TRUST_WALLET]
|
48
|
+
},
|
49
|
+
[b.BSC]: {
|
50
|
+
chainId: "0x38",
|
51
|
+
chainName: "BNB Smart Chain",
|
52
|
+
nativeCurrency: { name: "BNB", symbol: "BNB", decimals: 18 },
|
53
|
+
rpcUrls: ["https://bsc-dataseed.binance.org/"],
|
54
|
+
blockExplorerUrls: ["https://bscscan.com/"],
|
55
|
+
supportedWallets: [N.METAMASK, N.TRUST_WALLET]
|
56
|
+
},
|
57
|
+
[b.TRON]: {
|
58
|
+
fullHost: "https://api.trongrid.io",
|
59
|
+
explorerUrl: "https://tronscan.org",
|
60
|
+
supportedWallets: [N.TRONLINK]
|
61
|
+
},
|
62
|
+
[b.ALGORAND]: {
|
63
|
+
network: "mainnet",
|
64
|
+
explorerUrl: "https://algoexplorer.io",
|
65
|
+
supportedWallets: [N.LUTE]
|
66
|
+
}
|
67
|
+
}, Ye = {
|
68
|
+
USDT: {
|
69
|
+
[b.ETHEREUM]: {
|
70
|
+
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
71
|
+
decimals: 6
|
72
|
+
},
|
73
|
+
[b.BSC]: {
|
74
|
+
address: "0x55d398326f99059fF775485246999027B3197955",
|
75
|
+
decimals: 18
|
76
|
+
},
|
77
|
+
[b.TRON]: {
|
78
|
+
address: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
79
|
+
decimals: 6
|
80
|
+
}
|
81
|
+
},
|
82
|
+
USDC: {
|
83
|
+
[b.ETHEREUM]: {
|
84
|
+
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
85
|
+
decimals: 6
|
86
|
+
},
|
87
|
+
[b.BSC]: {
|
88
|
+
address: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
|
89
|
+
decimals: 18
|
90
|
+
},
|
91
|
+
[b.TRON]: {
|
92
|
+
address: "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",
|
93
|
+
decimals: 6
|
94
|
+
}
|
95
|
+
},
|
96
|
+
ALGO: {
|
97
|
+
[b.ALGORAND]: {
|
98
|
+
address: "native",
|
99
|
+
decimals: 6
|
100
|
+
}
|
101
|
+
}
|
102
|
+
};
|
103
|
+
let _ = null;
|
104
|
+
const Xe = () => R(void 0, null, function* () {
|
105
|
+
if (_)
|
106
|
+
return _;
|
107
|
+
try {
|
108
|
+
if (typeof window != "undefined" && window.Web3)
|
109
|
+
return _ = window.Web3, _;
|
110
|
+
const s = yield import("web3");
|
111
|
+
return _ = s.default || s.Web3 || s, _;
|
112
|
+
} catch (s) {
|
113
|
+
throw console.error("Failed to load Web3:", s), new Error("Web3 is required for blockchain transactions. Please ensure web3 is installed: npm install web3");
|
114
|
+
}
|
115
|
+
}), ue = () => {
|
116
|
+
const s = {
|
117
|
+
[N.METAMASK]: !1,
|
118
|
+
[N.TRUST_WALLET]: !1,
|
119
|
+
[N.TRONLINK]: !1,
|
120
|
+
[N.LUTE]: !1
|
121
|
+
};
|
122
|
+
if (typeof window == "undefined")
|
123
|
+
return s;
|
124
|
+
try {
|
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 (t) {
|
127
|
+
console.warn("Error detecting wallets:", t);
|
128
|
+
}
|
129
|
+
return s;
|
130
|
+
}, Ze = (s) => {
|
131
|
+
const t = de[s];
|
132
|
+
if (!t)
|
133
|
+
return [];
|
134
|
+
const e = ue();
|
135
|
+
return t.supportedWallets.filter((i) => e[i]);
|
136
|
+
}, et = (s, t) => R(void 0, null, function* () {
|
137
|
+
switch (s) {
|
138
|
+
case N.METAMASK:
|
139
|
+
return yield tt(t);
|
140
|
+
case N.TRONLINK:
|
141
|
+
return yield rt();
|
142
|
+
case N.TRUST_WALLET:
|
143
|
+
return yield st(t);
|
144
|
+
case N.LUTE:
|
145
|
+
return yield nt();
|
146
|
+
default:
|
147
|
+
throw new Error(`Unsupported wallet type: ${s}`);
|
148
|
+
}
|
149
|
+
}), tt = (s) => R(void 0, null, function* () {
|
150
|
+
if (typeof window == "undefined" || !window.ethereum || !window.ethereum.isMetaMask)
|
151
|
+
throw new Error("MetaMask is not installed. Please install MetaMask extension.");
|
152
|
+
try {
|
153
|
+
const t = yield window.ethereum.request({
|
154
|
+
method: "eth_requestAccounts"
|
155
|
+
});
|
156
|
+
if (!t || t.length === 0)
|
157
|
+
throw new Error("No accounts found. Please unlock MetaMask.");
|
158
|
+
const e = de[s];
|
159
|
+
return e && e.chainId && (yield be(e)), {
|
160
|
+
address: t[0],
|
161
|
+
network: s,
|
162
|
+
walletType: N.METAMASK
|
163
|
+
};
|
164
|
+
} catch (t) {
|
165
|
+
throw t.code === 4001 ? new Error("User rejected the connection request") : new Error(`Failed to connect MetaMask: ${t.message}`);
|
166
|
+
}
|
167
|
+
}), rt = () => R(void 0, null, function* () {
|
168
|
+
var i;
|
169
|
+
if (typeof window == "undefined" || !window.tronWeb)
|
170
|
+
throw new Error("TronLink is not installed. Please install TronLink extension.");
|
171
|
+
let s = 0;
|
172
|
+
const t = 10;
|
173
|
+
for (; !window.tronWeb.ready && s < t; )
|
174
|
+
yield new Promise((c) => setTimeout(c, 1e3)), s++;
|
175
|
+
if (!window.tronWeb.ready)
|
176
|
+
throw new Error("TronLink is not ready. Please unlock your TronLink wallet and try again.");
|
177
|
+
const e = (i = window.tronWeb.defaultAddress) == null ? void 0 : i.base58;
|
178
|
+
if (!e)
|
179
|
+
throw new Error("No account found in TronLink. Please make sure you have an account set up.");
|
180
|
+
return {
|
181
|
+
address: e,
|
182
|
+
network: b.TRON,
|
183
|
+
walletType: N.TRONLINK
|
184
|
+
};
|
185
|
+
}), st = (s) => R(void 0, null, function* () {
|
186
|
+
if (typeof window == "undefined" || !window.ethereum || !window.ethereum.isTrust)
|
187
|
+
throw new Error("Trust Wallet is not installed. Please install Trust Wallet extension.");
|
188
|
+
try {
|
189
|
+
const t = yield window.ethereum.request({
|
190
|
+
method: "eth_requestAccounts"
|
191
|
+
});
|
192
|
+
if (!t || t.length === 0)
|
193
|
+
throw new Error("No accounts found. Please unlock Trust Wallet.");
|
194
|
+
const e = de[s];
|
195
|
+
return e && e.chainId && (yield be(e)), {
|
196
|
+
address: t[0],
|
197
|
+
network: s,
|
198
|
+
walletType: N.TRUST_WALLET
|
199
|
+
};
|
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
|
+
}
|
203
|
+
}), nt = () => R(void 0, null, function* () {
|
204
|
+
if (typeof window == "undefined" || !window.algorand || !window.algorand.isLute)
|
205
|
+
throw new Error("Lute wallet is not installed. Please install Lute wallet extension.");
|
206
|
+
try {
|
207
|
+
const s = yield window.algorand.connect();
|
208
|
+
if (!s || s.length === 0)
|
209
|
+
throw new Error("No accounts found. Please unlock Lute wallet.");
|
210
|
+
return {
|
211
|
+
address: s[0],
|
212
|
+
network: b.ALGORAND,
|
213
|
+
walletType: N.LUTE
|
214
|
+
};
|
215
|
+
} catch (s) {
|
216
|
+
throw new Error(`Failed to connect Lute wallet: ${s.message}`);
|
217
|
+
}
|
218
|
+
}), be = (s) => R(void 0, null, function* () {
|
219
|
+
if (typeof window == "undefined" || !window.ethereum)
|
220
|
+
throw new Error("Ethereum provider not found");
|
221
|
+
try {
|
222
|
+
yield window.ethereum.request({
|
223
|
+
method: "wallet_switchEthereumChain",
|
224
|
+
params: [{ chainId: s.chainId }]
|
225
|
+
});
|
226
|
+
} catch (t) {
|
227
|
+
if (t.code === 4902)
|
228
|
+
try {
|
229
|
+
yield window.ethereum.request({
|
230
|
+
method: "wallet_addEthereumChain",
|
231
|
+
params: [s]
|
232
|
+
});
|
233
|
+
} catch (e) {
|
234
|
+
throw new Error(`Failed to add ${s.chainName} to wallet: ${e.message}`);
|
235
|
+
}
|
236
|
+
else
|
237
|
+
throw t.code === 4001 ? new Error("User rejected network switch request") : new Error(`Failed to switch to ${s.chainName}: ${t.message}`);
|
238
|
+
}
|
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
|
+
case N.METAMASK:
|
243
|
+
case N.TRUST_WALLET:
|
244
|
+
return yield at(c, u, y, x, r);
|
245
|
+
case N.TRONLINK:
|
246
|
+
return yield it(u, y, x, r);
|
247
|
+
case N.LUTE:
|
248
|
+
return yield lt(c, u, y);
|
249
|
+
default:
|
250
|
+
throw new Error(`Unsupported wallet type: ${e}`);
|
251
|
+
}
|
252
|
+
}), at = (s, t, e, i, c) => R(void 0, null, function* () {
|
253
|
+
if (typeof window == "undefined" || !window.ethereum)
|
254
|
+
throw new Error("Ethereum provider not found");
|
255
|
+
try {
|
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
|
+
);
|
259
|
+
if (i && i !== "native") {
|
260
|
+
const r = [
|
261
|
+
{
|
262
|
+
constant: !1,
|
263
|
+
inputs: [
|
264
|
+
{ name: "_to", type: "address" },
|
265
|
+
{ name: "_value", type: "uint256" }
|
266
|
+
],
|
267
|
+
name: "transfer",
|
268
|
+
outputs: [{ name: "", type: "bool" }],
|
269
|
+
payable: !1,
|
270
|
+
stateMutability: "nonpayable",
|
271
|
+
type: "function"
|
272
|
+
}
|
273
|
+
];
|
274
|
+
return (yield new y.eth.Contract(r, i).methods.transfer(t, x).send({ from: s })).transactionHash;
|
275
|
+
} else
|
276
|
+
return (yield y.eth.sendTransaction({
|
277
|
+
from: s,
|
278
|
+
to: t,
|
279
|
+
value: x
|
280
|
+
})).transactionHash;
|
281
|
+
} catch (u) {
|
282
|
+
throw u.code === 4001 ? new Error("Transaction was rejected by user") : new Error(`Transaction failed: ${u.message}`);
|
283
|
+
}
|
284
|
+
}), it = (s, t, e, i) => R(void 0, null, function* () {
|
285
|
+
if (typeof window == "undefined" || !window.tronWeb || !window.tronWeb.ready)
|
286
|
+
throw new Error("TronLink is not ready");
|
287
|
+
try {
|
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
|
+
feeLimit: 1e8,
|
291
|
+
callValue: 0
|
292
|
+
}) : (yield window.tronWeb.trx.sendTransaction(s, c)).txid;
|
293
|
+
} catch (c) {
|
294
|
+
throw new Error(`TRON transaction failed: ${c.message}`);
|
295
|
+
}
|
296
|
+
}), lt = (s, t, e) => R(void 0, null, function* () {
|
297
|
+
if (typeof window == "undefined" || !window.algorand)
|
298
|
+
throw new Error("Algorand wallet is not available");
|
299
|
+
try {
|
300
|
+
const i = Math.floor(parseFloat(e) * 1e6), c = {
|
301
|
+
from: s,
|
302
|
+
to: t,
|
303
|
+
amount: i,
|
304
|
+
type: "pay"
|
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
|
+
}
|
310
|
+
}), ct = (s) => ({
|
311
|
+
[N.METAMASK]: "https://metamask.io/",
|
312
|
+
[N.TRONLINK]: "https://www.tronlink.org/",
|
313
|
+
[N.TRUST_WALLET]: "https://trustwallet.com/",
|
314
|
+
[N.LUTE]: "https://lute.app/"
|
315
|
+
})[s] || "";
|
316
|
+
let U = {
|
31
317
|
apiKey: null,
|
32
318
|
apiSecret: null,
|
33
319
|
apiUrl: "http://localhost:9000",
|
34
320
|
merchantWalletAddresses: {}
|
35
321
|
// Changed to object for multi-network support
|
36
322
|
};
|
37
|
-
const
|
38
|
-
|
39
|
-
apiUrl:
|
40
|
-
apiKey:
|
41
|
-
hasWalletAddresses: Object.keys(
|
323
|
+
const dt = (s) => {
|
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
|
42
328
|
});
|
43
|
-
},
|
329
|
+
}, Y = () => ({
|
44
330
|
"Content-Type": "application/json",
|
45
|
-
"x-api-key":
|
46
|
-
"x-api-secret":
|
47
|
-
}),
|
331
|
+
"x-api-key": U.apiKey,
|
332
|
+
"x-api-secret": U.apiSecret
|
333
|
+
}), ut = (s) => R(void 0, null, function* () {
|
48
334
|
try {
|
49
|
-
console.log("Creating payment with data:",
|
50
|
-
const
|
51
|
-
merchantWalletAddresses:
|
52
|
-
}),
|
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`, {
|
53
339
|
method: "POST",
|
54
|
-
headers:
|
55
|
-
body: JSON.stringify(
|
340
|
+
headers: Y(),
|
341
|
+
body: JSON.stringify(t)
|
56
342
|
});
|
57
|
-
if (console.log("Create payment response status:",
|
58
|
-
const
|
59
|
-
throw console.error("Error creating payment:",
|
60
|
-
}
|
61
|
-
const
|
62
|
-
return console.log("Create payment response data:",
|
63
|
-
} catch (
|
64
|
-
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;
|
65
351
|
}
|
66
|
-
}),
|
352
|
+
}), Bt = (s) => R(void 0, null, function* () {
|
67
353
|
try {
|
68
|
-
console.log("Getting payment:",
|
69
|
-
const
|
354
|
+
console.log("Getting payment:", s);
|
355
|
+
const t = yield fetch(`${U.apiUrl}/api/payments/${s}`, {
|
70
356
|
method: "GET",
|
71
|
-
headers:
|
357
|
+
headers: Y()
|
72
358
|
});
|
73
|
-
if (!
|
74
|
-
const
|
75
|
-
throw console.error("Error getting payment:",
|
76
|
-
}
|
77
|
-
const
|
78
|
-
return console.log("Get payment response:",
|
79
|
-
} catch (
|
80
|
-
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;
|
81
367
|
}
|
82
|
-
}),
|
368
|
+
}), ht = (s) => R(void 0, null, function* () {
|
83
369
|
try {
|
84
|
-
console.log("Processing payment with data:",
|
85
|
-
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`, {
|
86
372
|
method: "POST",
|
87
|
-
headers:
|
88
|
-
body: JSON.stringify(
|
373
|
+
headers: Y(),
|
374
|
+
body: JSON.stringify(s)
|
89
375
|
});
|
90
|
-
if (console.log("Process payment response status:",
|
91
|
-
const
|
92
|
-
throw console.error("Error processing payment:",
|
93
|
-
}
|
94
|
-
const
|
95
|
-
return console.log("Process payment response data:",
|
96
|
-
} catch (
|
97
|
-
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;
|
98
384
|
}
|
99
|
-
}),
|
100
|
-
if (!lr())
|
101
|
-
throw new Error("MetaMask is not installed");
|
385
|
+
}), Wt = () => R(void 0, null, function* () {
|
102
386
|
try {
|
103
|
-
|
104
|
-
|
105
|
-
|
387
|
+
const s = yield fetch(`${U.apiUrl}/api/networks`, {
|
388
|
+
method: "GET",
|
389
|
+
headers: Y()
|
390
|
+
});
|
391
|
+
if (!s.ok) {
|
392
|
+
const e = yield s.json();
|
393
|
+
throw new Error(e.error || `Failed to get networks: ${s.status}`);
|
394
|
+
}
|
395
|
+
return yield s.json();
|
396
|
+
} catch (s) {
|
397
|
+
throw console.error("Get supported networks error:", s), s;
|
106
398
|
}
|
107
|
-
})
|
108
|
-
|
399
|
+
}), Qt = () => R(void 0, null, function* () {
|
400
|
+
try {
|
401
|
+
const s = yield fetch(`${U.apiUrl}/api/merchants/profile`, {
|
402
|
+
method: "GET",
|
403
|
+
headers: Y()
|
404
|
+
});
|
405
|
+
if (!s.ok) {
|
406
|
+
const e = yield s.json();
|
407
|
+
throw new Error(e.error || `Failed to get merchant profile: ${s.status}`);
|
408
|
+
}
|
409
|
+
const t = yield s.json();
|
410
|
+
return t.merchant && t.merchant.walletAddresses && (U.merchantWalletAddresses = z(z({}, U.merchantWalletAddresses), t.merchant.walletAddresses)), t;
|
411
|
+
} catch (s) {
|
412
|
+
throw console.error("Get merchant profile error:", s), s;
|
413
|
+
}
|
414
|
+
}), zt = (s, t) => R(void 0, null, function* () {
|
415
|
+
try {
|
416
|
+
const e = yield fetch(`${U.apiUrl}/api/wallets/validate`, {
|
417
|
+
method: "POST",
|
418
|
+
headers: Y(),
|
419
|
+
body: JSON.stringify({ address: s, network: t })
|
420
|
+
});
|
421
|
+
if (!e.ok) {
|
422
|
+
const c = yield e.json();
|
423
|
+
throw new Error(c.error || `Failed to validate address: ${e.status}`);
|
424
|
+
}
|
425
|
+
return yield e.json();
|
426
|
+
} catch (e) {
|
427
|
+
throw console.error("Validate wallet address error:", e), e;
|
428
|
+
}
|
429
|
+
}), Gt = (s = "ethereum") => {
|
430
|
+
const e = {
|
431
|
+
ethereum: "0x",
|
432
|
+
bsc: "0x",
|
433
|
+
tron: "",
|
434
|
+
algorand: ""
|
435
|
+
}[s] || "0x", i = Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
436
|
+
return `${e}${i}`;
|
437
|
+
};
|
438
|
+
var Ne = { exports: {} }, ne = {};
|
109
439
|
/**
|
110
440
|
* @license React
|
111
441
|
* react-jsx-runtime.production.min.js
|
@@ -115,745 +445,129 @@ var Be = { exports: {} }, Ce = {};
|
|
115
445
|
* This source code is licensed under the MIT license found in the
|
116
446
|
* LICENSE file in the root directory of this source tree.
|
117
447
|
*/
|
118
|
-
var
|
119
|
-
function
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
d.call(t, r) && !m.hasOwnProperty(r) && (l[r] = t[r]);
|
129
|
-
if (y && y.defaultProps)
|
130
|
-
for (r in t = y.defaultProps, t)
|
131
|
-
l[r] === void 0 && (l[r] = t[r]);
|
132
|
-
return { $$typeof: a, type: y, key: c, ref: w, props: l, _owner: h.current };
|
133
|
-
}
|
134
|
-
return Ce.Fragment = n, Ce.jsx = b, Ce.jsxs = b, Ce;
|
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
|
+
if (s && s.defaultProps)
|
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 };
|
135
458
|
}
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
* LICENSE file in the root directory of this source tree.
|
145
|
-
*/
|
146
|
-
var ut;
|
147
|
-
function ur() {
|
148
|
-
return ut || (ut = 1, process.env.NODE_ENV !== "production" && function() {
|
149
|
-
var o = B, a = Symbol.for("react.element"), n = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), h = Symbol.for("react.strict_mode"), m = Symbol.for("react.profiler"), b = Symbol.for("react.provider"), y = Symbol.for("react.context"), t = Symbol.for("react.forward_ref"), s = Symbol.for("react.suspense"), r = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), c = Symbol.for("react.lazy"), w = Symbol.for("react.offscreen"), u = Symbol.iterator, p = "@@iterator";
|
150
|
-
function v(e) {
|
151
|
-
if (e === null || typeof e != "object")
|
152
|
-
return null;
|
153
|
-
var f = u && e[u] || e[p];
|
154
|
-
return typeof f == "function" ? f : null;
|
155
|
-
}
|
156
|
-
var T = o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
157
|
-
function N(e) {
|
158
|
-
{
|
159
|
-
for (var f = arguments.length, g = new Array(f > 1 ? f - 1 : 0), E = 1; E < f; E++)
|
160
|
-
g[E - 1] = arguments[E];
|
161
|
-
x("error", e, g);
|
162
|
-
}
|
163
|
-
}
|
164
|
-
function x(e, f, g) {
|
165
|
-
{
|
166
|
-
var E = T.ReactDebugCurrentFrame, M = E.getStackAddendum();
|
167
|
-
M !== "" && (f += "%s", g = g.concat([M]));
|
168
|
-
var L = g.map(function(S) {
|
169
|
-
return String(S);
|
170
|
-
});
|
171
|
-
L.unshift("Warning: " + f), Function.prototype.apply.call(console[e], console, L);
|
172
|
-
}
|
173
|
-
}
|
174
|
-
var D = !1, I = !1, Z = !1, ae = !1, R = !1, P;
|
175
|
-
P = Symbol.for("react.module.reference");
|
176
|
-
function oe(e) {
|
177
|
-
return !!(typeof e == "string" || typeof e == "function" || e === d || e === m || R || e === h || e === s || e === r || ae || e === w || D || I || Z || typeof e == "object" && e !== null && (e.$$typeof === c || e.$$typeof === l || e.$$typeof === b || e.$$typeof === y || e.$$typeof === t || // This needs to include all possible module reference object
|
178
|
-
// types supported by any Flight configuration anywhere since
|
179
|
-
// we don't know which Flight build this will end up being used
|
180
|
-
// with.
|
181
|
-
e.$$typeof === P || e.getModuleId !== void 0));
|
182
|
-
}
|
183
|
-
function K(e, f, g) {
|
184
|
-
var E = e.displayName;
|
185
|
-
if (E)
|
186
|
-
return E;
|
187
|
-
var M = f.displayName || f.name || "";
|
188
|
-
return M !== "" ? g + "(" + M + ")" : g;
|
189
|
-
}
|
190
|
-
function $(e) {
|
191
|
-
return e.displayName || "Context";
|
192
|
-
}
|
193
|
-
function Y(e) {
|
194
|
-
if (e == null)
|
195
|
-
return null;
|
196
|
-
if (typeof e.tag == "number" && N("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
197
|
-
return e.displayName || e.name || null;
|
198
|
-
if (typeof e == "string")
|
199
|
-
return e;
|
200
|
-
switch (e) {
|
201
|
-
case d:
|
202
|
-
return "Fragment";
|
203
|
-
case n:
|
204
|
-
return "Portal";
|
205
|
-
case m:
|
206
|
-
return "Profiler";
|
207
|
-
case h:
|
208
|
-
return "StrictMode";
|
209
|
-
case s:
|
210
|
-
return "Suspense";
|
211
|
-
case r:
|
212
|
-
return "SuspenseList";
|
213
|
-
}
|
214
|
-
if (typeof e == "object")
|
215
|
-
switch (e.$$typeof) {
|
216
|
-
case y:
|
217
|
-
var f = e;
|
218
|
-
return $(f) + ".Consumer";
|
219
|
-
case b:
|
220
|
-
var g = e;
|
221
|
-
return $(g._context) + ".Provider";
|
222
|
-
case t:
|
223
|
-
return K(e, e.render, "ForwardRef");
|
224
|
-
case l:
|
225
|
-
var E = e.displayName || null;
|
226
|
-
return E !== null ? E : Y(e.type) || "Memo";
|
227
|
-
case c: {
|
228
|
-
var M = e, L = M._payload, S = M._init;
|
229
|
-
try {
|
230
|
-
return Y(S(L));
|
231
|
-
} catch (j) {
|
232
|
-
return null;
|
233
|
-
}
|
234
|
-
}
|
235
|
-
}
|
236
|
-
return null;
|
237
|
-
}
|
238
|
-
var Q = Object.assign, F = 0, se, ne, ue, ie, ee, me, de;
|
239
|
-
function ge() {
|
240
|
-
}
|
241
|
-
ge.__reactDisabledLog = !0;
|
242
|
-
function _() {
|
243
|
-
{
|
244
|
-
if (F === 0) {
|
245
|
-
se = console.log, ne = console.info, ue = console.warn, ie = console.error, ee = console.group, me = console.groupCollapsed, de = console.groupEnd;
|
246
|
-
var e = {
|
247
|
-
configurable: !0,
|
248
|
-
enumerable: !0,
|
249
|
-
value: ge,
|
250
|
-
writable: !0
|
251
|
-
};
|
252
|
-
Object.defineProperties(console, {
|
253
|
-
info: e,
|
254
|
-
log: e,
|
255
|
-
warn: e,
|
256
|
-
error: e,
|
257
|
-
group: e,
|
258
|
-
groupCollapsed: e,
|
259
|
-
groupEnd: e
|
260
|
-
});
|
261
|
-
}
|
262
|
-
F++;
|
263
|
-
}
|
264
|
-
}
|
265
|
-
function Pe() {
|
266
|
-
{
|
267
|
-
if (F--, F === 0) {
|
268
|
-
var e = {
|
269
|
-
configurable: !0,
|
270
|
-
enumerable: !0,
|
271
|
-
writable: !0
|
272
|
-
};
|
273
|
-
Object.defineProperties(console, {
|
274
|
-
log: Q({}, e, {
|
275
|
-
value: se
|
276
|
-
}),
|
277
|
-
info: Q({}, e, {
|
278
|
-
value: ne
|
279
|
-
}),
|
280
|
-
warn: Q({}, e, {
|
281
|
-
value: ue
|
282
|
-
}),
|
283
|
-
error: Q({}, e, {
|
284
|
-
value: ie
|
285
|
-
}),
|
286
|
-
group: Q({}, e, {
|
287
|
-
value: ee
|
288
|
-
}),
|
289
|
-
groupCollapsed: Q({}, e, {
|
290
|
-
value: me
|
291
|
-
}),
|
292
|
-
groupEnd: Q({}, e, {
|
293
|
-
value: de
|
294
|
-
})
|
295
|
-
});
|
296
|
-
}
|
297
|
-
F < 0 && N("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
298
|
-
}
|
299
|
-
}
|
300
|
-
var pe = T.ReactCurrentDispatcher, Ne;
|
301
|
-
function we(e, f, g) {
|
302
|
-
{
|
303
|
-
if (Ne === void 0)
|
304
|
-
try {
|
305
|
-
throw Error();
|
306
|
-
} catch (M) {
|
307
|
-
var E = M.stack.trim().match(/\n( *(at )?)/);
|
308
|
-
Ne = E && E[1] || "";
|
309
|
-
}
|
310
|
-
return `
|
311
|
-
` + Ne + e;
|
312
|
-
}
|
313
|
-
}
|
314
|
-
var Re = !1, ye;
|
315
|
-
{
|
316
|
-
var Oe = typeof WeakMap == "function" ? WeakMap : Map;
|
317
|
-
ye = new Oe();
|
318
|
-
}
|
319
|
-
function O(e, f) {
|
320
|
-
if (!e || Re)
|
321
|
-
return "";
|
322
|
-
{
|
323
|
-
var g = ye.get(e);
|
324
|
-
if (g !== void 0)
|
325
|
-
return g;
|
326
|
-
}
|
327
|
-
var E;
|
328
|
-
Re = !0;
|
329
|
-
var M = Error.prepareStackTrace;
|
330
|
-
Error.prepareStackTrace = void 0;
|
331
|
-
var L;
|
332
|
-
L = pe.current, pe.current = null, _();
|
333
|
-
try {
|
334
|
-
if (f) {
|
335
|
-
var S = function() {
|
336
|
-
throw Error();
|
337
|
-
};
|
338
|
-
if (Object.defineProperty(S.prototype, "props", {
|
339
|
-
set: function() {
|
340
|
-
throw Error();
|
341
|
-
}
|
342
|
-
}), typeof Reflect == "object" && Reflect.construct) {
|
343
|
-
try {
|
344
|
-
Reflect.construct(S, []);
|
345
|
-
} catch (J) {
|
346
|
-
E = J;
|
347
|
-
}
|
348
|
-
Reflect.construct(e, [], S);
|
349
|
-
} else {
|
350
|
-
try {
|
351
|
-
S.call();
|
352
|
-
} catch (J) {
|
353
|
-
E = J;
|
354
|
-
}
|
355
|
-
e.call(S.prototype);
|
356
|
-
}
|
357
|
-
} else {
|
358
|
-
try {
|
359
|
-
throw Error();
|
360
|
-
} catch (J) {
|
361
|
-
E = J;
|
362
|
-
}
|
363
|
-
e();
|
364
|
-
}
|
365
|
-
} catch (J) {
|
366
|
-
if (J && E && typeof J.stack == "string") {
|
367
|
-
for (var j = J.stack.split(`
|
368
|
-
`), q = E.stack.split(`
|
369
|
-
`), W = j.length - 1, z = q.length - 1; W >= 1 && z >= 0 && j[W] !== q[z]; )
|
370
|
-
z--;
|
371
|
-
for (; W >= 1 && z >= 0; W--, z--)
|
372
|
-
if (j[W] !== q[z]) {
|
373
|
-
if (W !== 1 || z !== 1)
|
374
|
-
do
|
375
|
-
if (W--, z--, z < 0 || j[W] !== q[z]) {
|
376
|
-
var re = `
|
377
|
-
` + j[W].replace(" at new ", " at ");
|
378
|
-
return e.displayName && re.includes("<anonymous>") && (re = re.replace("<anonymous>", e.displayName)), typeof e == "function" && ye.set(e, re), re;
|
379
|
-
}
|
380
|
-
while (W >= 1 && z >= 0);
|
381
|
-
break;
|
382
|
-
}
|
383
|
-
}
|
384
|
-
} finally {
|
385
|
-
Re = !1, pe.current = L, Pe(), Error.prepareStackTrace = M;
|
386
|
-
}
|
387
|
-
var Ee = e ? e.displayName || e.name : "", fe = Ee ? we(Ee) : "";
|
388
|
-
return typeof e == "function" && ye.set(e, fe), fe;
|
389
|
-
}
|
390
|
-
function V(e, f, g) {
|
391
|
-
return O(e, !1);
|
392
|
-
}
|
393
|
-
function te(e) {
|
394
|
-
var f = e.prototype;
|
395
|
-
return !!(f && f.isReactComponent);
|
396
|
-
}
|
397
|
-
function ve(e, f, g) {
|
398
|
-
if (e == null)
|
399
|
-
return "";
|
400
|
-
if (typeof e == "function")
|
401
|
-
return O(e, te(e));
|
402
|
-
if (typeof e == "string")
|
403
|
-
return we(e);
|
404
|
-
switch (e) {
|
405
|
-
case s:
|
406
|
-
return we("Suspense");
|
407
|
-
case r:
|
408
|
-
return we("SuspenseList");
|
409
|
-
}
|
410
|
-
if (typeof e == "object")
|
411
|
-
switch (e.$$typeof) {
|
412
|
-
case t:
|
413
|
-
return V(e.render);
|
414
|
-
case l:
|
415
|
-
return ve(e.type, f, g);
|
416
|
-
case c: {
|
417
|
-
var E = e, M = E._payload, L = E._init;
|
418
|
-
try {
|
419
|
-
return ve(L(M), f, g);
|
420
|
-
} catch (S) {
|
421
|
-
}
|
422
|
-
}
|
423
|
-
}
|
424
|
-
return "";
|
425
|
-
}
|
426
|
-
var le = Object.prototype.hasOwnProperty, Ke = {}, Ye = T.ReactDebugCurrentFrame;
|
427
|
-
function Se(e) {
|
428
|
-
if (e) {
|
429
|
-
var f = e._owner, g = ve(e.type, e._source, f ? f.type : null);
|
430
|
-
Ye.setExtraStackFrame(g);
|
431
|
-
} else
|
432
|
-
Ye.setExtraStackFrame(null);
|
433
|
-
}
|
434
|
-
function kt(e, f, g, E, M) {
|
435
|
-
{
|
436
|
-
var L = Function.call.bind(le);
|
437
|
-
for (var S in e)
|
438
|
-
if (L(e, S)) {
|
439
|
-
var j = void 0;
|
440
|
-
try {
|
441
|
-
if (typeof e[S] != "function") {
|
442
|
-
var q = Error((E || "React class") + ": " + g + " type `" + S + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[S] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
443
|
-
throw q.name = "Invariant Violation", q;
|
444
|
-
}
|
445
|
-
j = e[S](f, S, E, g, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
446
|
-
} catch (W) {
|
447
|
-
j = W;
|
448
|
-
}
|
449
|
-
j && !(j instanceof Error) && (Se(M), N("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", E || "React class", g, S, typeof j), Se(null)), j instanceof Error && !(j.message in Ke) && (Ke[j.message] = !0, Se(M), N("Failed %s type: %s", g, j.message), Se(null));
|
450
|
-
}
|
451
|
-
}
|
452
|
-
}
|
453
|
-
var Mt = Array.isArray;
|
454
|
-
function Le(e) {
|
455
|
-
return Mt(e);
|
456
|
-
}
|
457
|
-
function Pt(e) {
|
458
|
-
{
|
459
|
-
var f = typeof Symbol == "function" && Symbol.toStringTag, g = f && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
460
|
-
return g;
|
461
|
-
}
|
462
|
-
}
|
463
|
-
function Ot(e) {
|
464
|
-
try {
|
465
|
-
return qe(e), !1;
|
466
|
-
} catch (f) {
|
467
|
-
return !0;
|
468
|
-
}
|
469
|
-
}
|
470
|
-
function qe(e) {
|
471
|
-
return "" + e;
|
472
|
-
}
|
473
|
-
function $e(e) {
|
474
|
-
if (Ot(e))
|
475
|
-
return N("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Pt(e)), qe(e);
|
476
|
-
}
|
477
|
-
var Te = T.ReactCurrentOwner, Lt = {
|
478
|
-
key: !0,
|
479
|
-
ref: !0,
|
480
|
-
__self: !0,
|
481
|
-
__source: !0
|
482
|
-
}, Je, Xe, De;
|
483
|
-
De = {};
|
484
|
-
function Dt(e) {
|
485
|
-
if (le.call(e, "ref")) {
|
486
|
-
var f = Object.getOwnPropertyDescriptor(e, "ref").get;
|
487
|
-
if (f && f.isReactWarning)
|
488
|
-
return !1;
|
489
|
-
}
|
490
|
-
return e.ref !== void 0;
|
491
|
-
}
|
492
|
-
function It(e) {
|
493
|
-
if (le.call(e, "key")) {
|
494
|
-
var f = Object.getOwnPropertyDescriptor(e, "key").get;
|
495
|
-
if (f && f.isReactWarning)
|
496
|
-
return !1;
|
497
|
-
}
|
498
|
-
return e.key !== void 0;
|
499
|
-
}
|
500
|
-
function Ft(e, f) {
|
501
|
-
if (typeof e.ref == "string" && Te.current && f && Te.current.stateNode !== f) {
|
502
|
-
var g = Y(Te.current.type);
|
503
|
-
De[g] || (N('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', Y(Te.current.type), e.ref), De[g] = !0);
|
504
|
-
}
|
505
|
-
}
|
506
|
-
function Ut(e, f) {
|
507
|
-
{
|
508
|
-
var g = function() {
|
509
|
-
Je || (Je = !0, N("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", f));
|
510
|
-
};
|
511
|
-
g.isReactWarning = !0, Object.defineProperty(e, "key", {
|
512
|
-
get: g,
|
513
|
-
configurable: !0
|
514
|
-
});
|
515
|
-
}
|
516
|
-
}
|
517
|
-
function _t(e, f) {
|
518
|
-
{
|
519
|
-
var g = function() {
|
520
|
-
Xe || (Xe = !0, N("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", f));
|
521
|
-
};
|
522
|
-
g.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
523
|
-
get: g,
|
524
|
-
configurable: !0
|
525
|
-
});
|
526
|
-
}
|
527
|
-
}
|
528
|
-
var Wt = function(e, f, g, E, M, L, S) {
|
529
|
-
var j = {
|
530
|
-
// This tag allows us to uniquely identify this as a React Element
|
531
|
-
$$typeof: a,
|
532
|
-
// Built-in properties that belong on the element
|
533
|
-
type: e,
|
534
|
-
key: f,
|
535
|
-
ref: g,
|
536
|
-
props: S,
|
537
|
-
// Record the component responsible for creating this element.
|
538
|
-
_owner: L
|
539
|
-
};
|
540
|
-
return j._store = {}, Object.defineProperty(j._store, "validated", {
|
541
|
-
configurable: !1,
|
542
|
-
enumerable: !1,
|
543
|
-
writable: !0,
|
544
|
-
value: !1
|
545
|
-
}), Object.defineProperty(j, "_self", {
|
546
|
-
configurable: !1,
|
547
|
-
enumerable: !1,
|
548
|
-
writable: !1,
|
549
|
-
value: E
|
550
|
-
}), Object.defineProperty(j, "_source", {
|
551
|
-
configurable: !1,
|
552
|
-
enumerable: !1,
|
553
|
-
writable: !1,
|
554
|
-
value: M
|
555
|
-
}), Object.freeze && (Object.freeze(j.props), Object.freeze(j)), j;
|
556
|
-
};
|
557
|
-
function Bt(e, f, g, E, M) {
|
558
|
-
{
|
559
|
-
var L, S = {}, j = null, q = null;
|
560
|
-
g !== void 0 && ($e(g), j = "" + g), It(f) && ($e(f.key), j = "" + f.key), Dt(f) && (q = f.ref, Ft(f, M));
|
561
|
-
for (L in f)
|
562
|
-
le.call(f, L) && !Lt.hasOwnProperty(L) && (S[L] = f[L]);
|
563
|
-
if (e && e.defaultProps) {
|
564
|
-
var W = e.defaultProps;
|
565
|
-
for (L in W)
|
566
|
-
S[L] === void 0 && (S[L] = W[L]);
|
567
|
-
}
|
568
|
-
if (j || q) {
|
569
|
-
var z = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
|
570
|
-
j && Ut(S, z), q && _t(S, z);
|
571
|
-
}
|
572
|
-
return Wt(e, j, q, M, E, Te.current, S);
|
573
|
-
}
|
574
|
-
}
|
575
|
-
var Ie = T.ReactCurrentOwner, Ze = T.ReactDebugCurrentFrame;
|
576
|
-
function xe(e) {
|
577
|
-
if (e) {
|
578
|
-
var f = e._owner, g = ve(e.type, e._source, f ? f.type : null);
|
579
|
-
Ze.setExtraStackFrame(g);
|
580
|
-
} else
|
581
|
-
Ze.setExtraStackFrame(null);
|
582
|
-
}
|
583
|
-
var Fe;
|
584
|
-
Fe = !1;
|
585
|
-
function Ue(e) {
|
586
|
-
return typeof e == "object" && e !== null && e.$$typeof === a;
|
587
|
-
}
|
588
|
-
function et() {
|
589
|
-
{
|
590
|
-
if (Ie.current) {
|
591
|
-
var e = Y(Ie.current.type);
|
592
|
-
if (e)
|
593
|
-
return `
|
594
|
-
|
595
|
-
Check the render method of \`` + e + "`.";
|
596
|
-
}
|
597
|
-
return "";
|
598
|
-
}
|
599
|
-
}
|
600
|
-
function zt(e) {
|
601
|
-
{
|
602
|
-
if (e !== void 0) {
|
603
|
-
var f = e.fileName.replace(/^.*[\\\/]/, ""), g = e.lineNumber;
|
604
|
-
return `
|
605
|
-
|
606
|
-
Check your code at ` + f + ":" + g + ".";
|
607
|
-
}
|
608
|
-
return "";
|
609
|
-
}
|
610
|
-
}
|
611
|
-
var tt = {};
|
612
|
-
function Qt(e) {
|
613
|
-
{
|
614
|
-
var f = et();
|
615
|
-
if (!f) {
|
616
|
-
var g = typeof e == "string" ? e : e.displayName || e.name;
|
617
|
-
g && (f = `
|
618
|
-
|
619
|
-
Check the top-level render call using <` + g + ">.");
|
620
|
-
}
|
621
|
-
return f;
|
622
|
-
}
|
623
|
-
}
|
624
|
-
function rt(e, f) {
|
625
|
-
{
|
626
|
-
if (!e._store || e._store.validated || e.key != null)
|
627
|
-
return;
|
628
|
-
e._store.validated = !0;
|
629
|
-
var g = Qt(f);
|
630
|
-
if (tt[g])
|
631
|
-
return;
|
632
|
-
tt[g] = !0;
|
633
|
-
var E = "";
|
634
|
-
e && e._owner && e._owner !== Ie.current && (E = " It was passed a child from " + Y(e._owner.type) + "."), xe(e), N('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', g, E), xe(null);
|
635
|
-
}
|
636
|
-
}
|
637
|
-
function nt(e, f) {
|
638
|
-
{
|
639
|
-
if (typeof e != "object")
|
640
|
-
return;
|
641
|
-
if (Le(e))
|
642
|
-
for (var g = 0; g < e.length; g++) {
|
643
|
-
var E = e[g];
|
644
|
-
Ue(E) && rt(E, f);
|
645
|
-
}
|
646
|
-
else if (Ue(e))
|
647
|
-
e._store && (e._store.validated = !0);
|
648
|
-
else if (e) {
|
649
|
-
var M = v(e);
|
650
|
-
if (typeof M == "function" && M !== e.entries)
|
651
|
-
for (var L = M.call(e), S; !(S = L.next()).done; )
|
652
|
-
Ue(S.value) && rt(S.value, f);
|
653
|
-
}
|
654
|
-
}
|
655
|
-
}
|
656
|
-
function Vt(e) {
|
657
|
-
{
|
658
|
-
var f = e.type;
|
659
|
-
if (f == null || typeof f == "string")
|
660
|
-
return;
|
661
|
-
var g;
|
662
|
-
if (typeof f == "function")
|
663
|
-
g = f.propTypes;
|
664
|
-
else if (typeof f == "object" && (f.$$typeof === t || // Note: Memo only checks outer props here.
|
665
|
-
// Inner props are checked in the reconciler.
|
666
|
-
f.$$typeof === l))
|
667
|
-
g = f.propTypes;
|
668
|
-
else
|
669
|
-
return;
|
670
|
-
if (g) {
|
671
|
-
var E = Y(f);
|
672
|
-
kt(g, e.props, "prop", E, e);
|
673
|
-
} else if (f.PropTypes !== void 0 && !Fe) {
|
674
|
-
Fe = !0;
|
675
|
-
var M = Y(f);
|
676
|
-
N("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", M || "Unknown");
|
677
|
-
}
|
678
|
-
typeof f.getDefaultProps == "function" && !f.getDefaultProps.isReactClassApproved && N("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
679
|
-
}
|
680
|
-
}
|
681
|
-
function Gt(e) {
|
682
|
-
{
|
683
|
-
for (var f = Object.keys(e.props), g = 0; g < f.length; g++) {
|
684
|
-
var E = f[g];
|
685
|
-
if (E !== "children" && E !== "key") {
|
686
|
-
xe(e), N("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", E), xe(null);
|
687
|
-
break;
|
688
|
-
}
|
689
|
-
}
|
690
|
-
e.ref !== null && (xe(e), N("Invalid attribute `ref` supplied to `React.Fragment`."), xe(null));
|
691
|
-
}
|
692
|
-
}
|
693
|
-
var st = {};
|
694
|
-
function at(e, f, g, E, M, L) {
|
695
|
-
{
|
696
|
-
var S = oe(e);
|
697
|
-
if (!S) {
|
698
|
-
var j = "";
|
699
|
-
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (j += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
700
|
-
var q = zt(M);
|
701
|
-
q ? j += q : j += et();
|
702
|
-
var W;
|
703
|
-
e === null ? W = "null" : Le(e) ? W = "array" : e !== void 0 && e.$$typeof === a ? (W = "<" + (Y(e.type) || "Unknown") + " />", j = " Did you accidentally export a JSX literal instead of a component?") : W = typeof e, N("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", W, j);
|
704
|
-
}
|
705
|
-
var z = Bt(e, f, g, M, L);
|
706
|
-
if (z == null)
|
707
|
-
return z;
|
708
|
-
if (S) {
|
709
|
-
var re = f.children;
|
710
|
-
if (re !== void 0)
|
711
|
-
if (E)
|
712
|
-
if (Le(re)) {
|
713
|
-
for (var Ee = 0; Ee < re.length; Ee++)
|
714
|
-
nt(re[Ee], e);
|
715
|
-
Object.freeze && Object.freeze(re);
|
716
|
-
} else
|
717
|
-
N("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
718
|
-
else
|
719
|
-
nt(re, e);
|
720
|
-
}
|
721
|
-
if (le.call(f, "key")) {
|
722
|
-
var fe = Y(e), J = Object.keys(f).filter(function(Jt) {
|
723
|
-
return Jt !== "key";
|
724
|
-
}), _e = J.length > 0 ? "{key: someKey, " + J.join(": ..., ") + ": ...}" : "{key: someKey}";
|
725
|
-
if (!st[fe + _e]) {
|
726
|
-
var $t = J.length > 0 ? "{" + J.join(": ..., ") + ": ...}" : "{}";
|
727
|
-
N(`A props object containing a "key" prop is being spread into JSX:
|
728
|
-
let props = %s;
|
729
|
-
<%s {...props} />
|
730
|
-
React keys must be passed directly to JSX without using spread:
|
731
|
-
let props = %s;
|
732
|
-
<%s key={someKey} {...props} />`, _e, fe, $t, fe), st[fe + _e] = !0;
|
733
|
-
}
|
734
|
-
}
|
735
|
-
return e === d ? Gt(z) : Vt(z), z;
|
736
|
-
}
|
737
|
-
}
|
738
|
-
function Ht(e, f, g) {
|
739
|
-
return at(e, f, g, !0);
|
740
|
-
}
|
741
|
-
function Kt(e, f, g) {
|
742
|
-
return at(e, f, g, !1);
|
743
|
-
}
|
744
|
-
var Yt = Kt, qt = Ht;
|
745
|
-
Ae.Fragment = d, Ae.jsx = Yt, Ae.jsxs = qt;
|
746
|
-
}()), Ae;
|
747
|
-
}
|
748
|
-
process.env.NODE_ENV === "production" ? Be.exports = cr() : Be.exports = ur();
|
749
|
-
var i = Be.exports;
|
750
|
-
const mt = ft(), dr = () => ht(mt), Qr = ({ initialTheme: o = "light", children: a }) => {
|
751
|
-
const [n, d] = H(o), h = () => {
|
752
|
-
d((m) => m === "light" ? "dark" : "light");
|
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");
|
753
467
|
};
|
754
|
-
return
|
755
|
-
document.documentElement.classList.remove("light", "dark"), document.documentElement.classList.add(
|
756
|
-
}, [
|
757
|
-
},
|
758
|
-
apiKey:
|
759
|
-
apiSecret:
|
760
|
-
apiUrl:
|
761
|
-
merchantWalletAddress:
|
468
|
+
return Z(() => {
|
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
|
+
apiKey: s,
|
473
|
+
apiSecret: t,
|
474
|
+
apiUrl: e = "http://localhost:9000",
|
475
|
+
merchantWalletAddress: i = null,
|
762
476
|
// New prop for merchant wallet address
|
763
|
-
merchantSolWalletAddress:
|
477
|
+
merchantSolWalletAddress: c = null,
|
764
478
|
// New prop for Solana wallet address
|
765
|
-
debug:
|
766
|
-
children:
|
479
|
+
debug: u = !1,
|
480
|
+
children: y
|
767
481
|
}) => {
|
768
|
-
const [
|
769
|
-
|
770
|
-
if (!
|
771
|
-
|
482
|
+
const [x, r] = D(!1), [n, a] = D(null), [l, d] = D(null);
|
483
|
+
Z(() => {
|
484
|
+
if (!s || !t) {
|
485
|
+
a("API key and secret are required");
|
772
486
|
return;
|
773
487
|
}
|
774
488
|
try {
|
775
|
-
|
776
|
-
apiKey:
|
777
|
-
apiSecret:
|
778
|
-
apiUrl:
|
779
|
-
merchantWalletAddress:
|
489
|
+
dt({
|
490
|
+
apiKey: s,
|
491
|
+
apiSecret: t,
|
492
|
+
apiUrl: e,
|
493
|
+
merchantWalletAddress: i,
|
780
494
|
// Pass wallet address to API service
|
781
|
-
merchantSolWalletAddress:
|
782
|
-
}),
|
783
|
-
apiKey:
|
784
|
-
apiUrl:
|
785
|
-
merchantWalletAddress:
|
786
|
-
merchantSolWalletAddress:
|
495
|
+
merchantSolWalletAddress: c
|
496
|
+
}), r(!0), u && console.log("Coinley SDK initialized with:", {
|
497
|
+
apiKey: s,
|
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"
|
787
501
|
});
|
788
|
-
} catch (
|
789
|
-
|
790
|
-
}
|
791
|
-
}, [
|
792
|
-
const
|
793
|
-
apiKey:
|
794
|
-
apiSecret:
|
795
|
-
apiUrl:
|
796
|
-
merchantWalletAddress:
|
797
|
-
merchantSolWalletAddress:
|
798
|
-
isInitialized:
|
799
|
-
error:
|
800
|
-
debug:
|
502
|
+
} catch (m) {
|
503
|
+
a(m.message), u && console.error("Coinley SDK initialization error:", m);
|
504
|
+
}
|
505
|
+
}, [s, t, e, i, c, u]);
|
506
|
+
const h = {
|
507
|
+
apiKey: s,
|
508
|
+
apiSecret: t,
|
509
|
+
apiUrl: e,
|
510
|
+
merchantWalletAddress: i,
|
511
|
+
merchantSolWalletAddress: c,
|
512
|
+
isInitialized: x,
|
513
|
+
error: n,
|
514
|
+
debug: u,
|
801
515
|
paymentData: l,
|
802
|
-
storePaymentData: (
|
516
|
+
storePaymentData: (m) => (d(m), m)
|
803
517
|
};
|
804
|
-
return /* @__PURE__ */
|
518
|
+
return /* @__PURE__ */ o.jsx(ke.Provider, { value: h, children: y });
|
805
519
|
};
|
806
|
-
var
|
807
|
-
for (var
|
808
|
-
|
809
|
-
if (
|
810
|
-
for (var
|
811
|
-
|
812
|
-
return
|
813
|
-
},
|
814
|
-
var
|
815
|
-
for (var
|
816
|
-
|
817
|
-
if (
|
818
|
-
for (var
|
819
|
-
|
820
|
-
return
|
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
|
+
if (se)
|
524
|
+
for (var e of se(t))
|
525
|
+
Ae.call(t, e) && pe(s, e, t[e]);
|
526
|
+
return s;
|
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
|
+
if (s != null && se)
|
532
|
+
for (var i of se(s))
|
533
|
+
t.indexOf(i) < 0 && Ae.call(s, i) && (e[i] = s[i]);
|
534
|
+
return e;
|
821
535
|
};
|
822
536
|
/**
|
823
537
|
* @license QR Code generator library (TypeScript)
|
824
538
|
* Copyright (c) Project Nayuki.
|
825
539
|
* SPDX-License-Identifier: MIT
|
826
540
|
*/
|
827
|
-
var
|
828
|
-
((
|
829
|
-
const
|
541
|
+
var K;
|
542
|
+
((s) => {
|
543
|
+
const t = class E {
|
830
544
|
/*-- Constructor (low level) and fields --*/
|
831
545
|
// Creates a new QR Code with the given version number,
|
832
546
|
// error correction level, data codeword bytes, and mask number.
|
833
547
|
// This is a low-level API that most users should not use directly.
|
834
548
|
// A mid-level API is the encodeSegments() function.
|
835
|
-
constructor(
|
836
|
-
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)
|
837
551
|
throw new RangeError("Version value out of range");
|
838
552
|
if (l < -1 || l > 7)
|
839
553
|
throw new RangeError("Mask value out of range");
|
840
|
-
this.size =
|
841
|
-
let
|
842
|
-
for (let
|
843
|
-
|
844
|
-
for (let
|
845
|
-
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());
|
846
560
|
this.drawFunctionPatterns();
|
847
|
-
const
|
848
|
-
if (this.drawCodewords(
|
849
|
-
let
|
850
|
-
for (let
|
851
|
-
this.applyMask(
|
852
|
-
const
|
853
|
-
|
561
|
+
const g = this.addEccAndInterleave(a);
|
562
|
+
if (this.drawCodewords(g), l == -1) {
|
563
|
+
let h = 1e9;
|
564
|
+
for (let m = 0; m < 8; m++) {
|
565
|
+
this.applyMask(m), this.drawFormatBits(m);
|
566
|
+
const f = this.getPenaltyScore();
|
567
|
+
f < h && (l = m, h = f), this.applyMask(m);
|
854
568
|
}
|
855
569
|
}
|
856
|
-
|
570
|
+
c(0 <= l && l <= 7), this.mask = l, this.applyMask(l), this.drawFormatBits(l), this.isFunction = [];
|
857
571
|
}
|
858
572
|
/*-- Static factory functions (high level) --*/
|
859
573
|
// Returns a QR Code representing the given Unicode text string at the given error correction level.
|
@@ -861,17 +575,17 @@ var he;
|
|
861
575
|
// Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
|
862
576
|
// QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
|
863
577
|
// ecl argument if it can be done without increasing the version.
|
864
|
-
static encodeText(
|
865
|
-
const
|
866
|
-
return
|
578
|
+
static encodeText(r, n) {
|
579
|
+
const a = s.QrSegment.makeSegments(r);
|
580
|
+
return E.encodeSegments(a, n);
|
867
581
|
}
|
868
582
|
// Returns a QR Code representing the given binary data at the given error correction level.
|
869
583
|
// This function always encodes using the binary segment mode, not any text mode. The maximum number of
|
870
584
|
// bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
|
871
585
|
// The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
|
872
|
-
static encodeBinary(
|
873
|
-
const
|
874
|
-
return
|
586
|
+
static encodeBinary(r, n) {
|
587
|
+
const a = s.QrSegment.makeBytes(r);
|
588
|
+
return E.encodeSegments([a], n);
|
875
589
|
}
|
876
590
|
/*-- Static factory functions (mid level) --*/
|
877
591
|
// Returns a QR Code representing the given segments with the given encoding parameters.
|
@@ -883,43 +597,43 @@ var he;
|
|
883
597
|
// This function allows the user to create a custom sequence of segments that switches
|
884
598
|
// between modes (such as alphanumeric and byte) to encode text in less space.
|
885
599
|
// This is a mid-level API; the high-level API is encodeText() and encodeBinary().
|
886
|
-
static encodeSegments(
|
887
|
-
if (!(
|
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)
|
888
602
|
throw new RangeError("Invalid value");
|
889
|
-
let
|
890
|
-
for (
|
891
|
-
const
|
892
|
-
if (
|
893
|
-
|
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;
|
894
608
|
break;
|
895
609
|
}
|
896
|
-
if (
|
610
|
+
if (h >= l)
|
897
611
|
throw new RangeError("Data too long");
|
898
612
|
}
|
899
|
-
for (const
|
900
|
-
|
901
|
-
let
|
902
|
-
for (const
|
903
|
-
|
904
|
-
for (const
|
905
|
-
|
613
|
+
for (const p of [E.Ecc.MEDIUM, E.Ecc.QUARTILE, E.Ecc.HIGH])
|
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);
|
906
620
|
}
|
907
|
-
|
908
|
-
const
|
909
|
-
|
910
|
-
for (let
|
911
|
-
|
912
|
-
let
|
913
|
-
for (;
|
914
|
-
|
915
|
-
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);
|
916
630
|
}
|
917
631
|
/*-- Accessor methods --*/
|
918
632
|
// Returns the color of the module (pixel) at the given coordinates, which is false
|
919
633
|
// for light or true for dark. The top left corner has the coordinates (x=0, y=0).
|
920
634
|
// If the given coordinates are out of bounds, then false (light) is returned.
|
921
|
-
getModule(
|
922
|
-
return 0 <=
|
635
|
+
getModule(r, n) {
|
636
|
+
return 0 <= r && r < this.size && 0 <= n && n < this.size && this.modules[n][r];
|
923
637
|
}
|
924
638
|
// Modified to expose modules for easy access
|
925
639
|
getModules() {
|
@@ -928,33 +642,33 @@ var he;
|
|
928
642
|
/*-- Private helper methods for constructor: Drawing function modules --*/
|
929
643
|
// Reads this object's version field, and draws and marks all function modules.
|
930
644
|
drawFunctionPatterns() {
|
931
|
-
for (let
|
932
|
-
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);
|
933
647
|
this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
|
934
|
-
const
|
935
|
-
for (let
|
936
|
-
for (let l = 0; l <
|
937
|
-
|
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]);
|
938
652
|
this.drawFormatBits(0), this.drawVersion();
|
939
653
|
}
|
940
654
|
// Draws two copies of the format bits (with its own error correction code)
|
941
655
|
// based on the given mask and this object's error correction level field.
|
942
|
-
drawFormatBits(
|
943
|
-
const
|
944
|
-
let
|
945
|
-
for (let
|
946
|
-
|
947
|
-
const l = (
|
948
|
-
|
949
|
-
for (let
|
950
|
-
this.setFunctionModule(8,
|
951
|
-
this.setFunctionModule(8, 7,
|
952
|
-
for (let
|
953
|
-
this.setFunctionModule(14 -
|
954
|
-
for (let
|
955
|
-
this.setFunctionModule(this.size - 1 -
|
956
|
-
for (let
|
957
|
-
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));
|
958
672
|
this.setFunctionModule(8, this.size - 8, !0);
|
959
673
|
}
|
960
674
|
// Draws two copies of the version bits (with its own error correction code),
|
@@ -962,144 +676,144 @@ var he;
|
|
962
676
|
drawVersion() {
|
963
677
|
if (this.version < 7)
|
964
678
|
return;
|
965
|
-
let
|
966
|
-
for (let
|
967
|
-
|
968
|
-
const
|
969
|
-
|
970
|
-
for (let
|
971
|
-
const l =
|
972
|
-
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);
|
973
687
|
}
|
974
688
|
}
|
975
689
|
// Draws a 9*9 finder pattern including the border separator,
|
976
690
|
// with the center module at (x, y). Modules can be out of bounds.
|
977
|
-
drawFinderPattern(
|
978
|
-
for (let
|
691
|
+
drawFinderPattern(r, n) {
|
692
|
+
for (let a = -4; a <= 4; a++)
|
979
693
|
for (let l = -4; l <= 4; l++) {
|
980
|
-
const
|
981
|
-
0 <=
|
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);
|
982
696
|
}
|
983
697
|
}
|
984
698
|
// Draws a 5*5 alignment pattern, with the center module
|
985
699
|
// at (x, y). All modules must be in bounds.
|
986
|
-
drawAlignmentPattern(
|
987
|
-
for (let
|
700
|
+
drawAlignmentPattern(r, n) {
|
701
|
+
for (let a = -2; a <= 2; a++)
|
988
702
|
for (let l = -2; l <= 2; l++)
|
989
|
-
this.setFunctionModule(
|
703
|
+
this.setFunctionModule(r + l, n + a, Math.max(Math.abs(l), Math.abs(a)) != 1);
|
990
704
|
}
|
991
705
|
// Sets the color of a module and marks it as a function module.
|
992
706
|
// Only used by the constructor. Coordinates must be in bounds.
|
993
|
-
setFunctionModule(
|
994
|
-
this.modules[
|
707
|
+
setFunctionModule(r, n, a) {
|
708
|
+
this.modules[n][r] = a, this.isFunction[n][r] = !0;
|
995
709
|
}
|
996
710
|
/*-- Private helper methods for constructor: Codewords and masking --*/
|
997
711
|
// Returns a new byte string representing the given data with the appropriate error correction
|
998
712
|
// codewords appended to it, based on this object's version and error correction level.
|
999
|
-
addEccAndInterleave(
|
1000
|
-
const
|
1001
|
-
if (
|
713
|
+
addEccAndInterleave(r) {
|
714
|
+
const n = this.version, a = this.errorCorrectionLevel;
|
715
|
+
if (r.length != E.getNumDataCodewords(n, a))
|
1002
716
|
throw new RangeError("Invalid argument");
|
1003
|
-
const l =
|
1004
|
-
let
|
1005
|
-
const
|
1006
|
-
for (let
|
1007
|
-
let
|
1008
|
-
|
1009
|
-
const
|
1010
|
-
|
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));
|
1011
725
|
}
|
1012
|
-
let
|
1013
|
-
for (let
|
1014
|
-
|
1015
|
-
(
|
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]);
|
1016
730
|
});
|
1017
|
-
return
|
731
|
+
return c(w.length == g), w;
|
1018
732
|
}
|
1019
733
|
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
|
1020
734
|
// data area of this QR Code. Function modules need to be marked off before this is called.
|
1021
|
-
drawCodewords(
|
1022
|
-
if (
|
735
|
+
drawCodewords(r) {
|
736
|
+
if (r.length != Math.floor(E.getNumRawDataModules(this.version) / 8))
|
1023
737
|
throw new RangeError("Invalid argument");
|
1024
|
-
let
|
1025
|
-
for (let
|
1026
|
-
|
738
|
+
let n = 0;
|
739
|
+
for (let a = this.size - 1; a >= 1; a -= 2) {
|
740
|
+
a == 6 && (a = 5);
|
1027
741
|
for (let l = 0; l < this.size; l++)
|
1028
|
-
for (let
|
1029
|
-
const
|
1030
|
-
!this.isFunction[
|
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++);
|
1031
745
|
}
|
1032
746
|
}
|
1033
|
-
|
747
|
+
c(n == r.length * 8);
|
1034
748
|
}
|
1035
749
|
// XORs the codeword modules in this QR Code with the given mask pattern.
|
1036
750
|
// The function modules must be marked and the codeword bits must be drawn
|
1037
751
|
// before masking. Due to the arithmetic of XOR, calling applyMask() with
|
1038
752
|
// the same mask value a second time will undo the mask. A final well-formed
|
1039
753
|
// QR Code needs exactly one (not zero, two, etc.) mask applied.
|
1040
|
-
applyMask(
|
1041
|
-
if (
|
754
|
+
applyMask(r) {
|
755
|
+
if (r < 0 || r > 7)
|
1042
756
|
throw new RangeError("Mask value out of range");
|
1043
|
-
for (let
|
1044
|
-
for (let
|
757
|
+
for (let n = 0; n < this.size; n++)
|
758
|
+
for (let a = 0; a < this.size; a++) {
|
1045
759
|
let l;
|
1046
|
-
switch (
|
760
|
+
switch (r) {
|
1047
761
|
case 0:
|
1048
|
-
l = (
|
762
|
+
l = (a + n) % 2 == 0;
|
1049
763
|
break;
|
1050
764
|
case 1:
|
1051
|
-
l =
|
765
|
+
l = n % 2 == 0;
|
1052
766
|
break;
|
1053
767
|
case 2:
|
1054
|
-
l =
|
768
|
+
l = a % 3 == 0;
|
1055
769
|
break;
|
1056
770
|
case 3:
|
1057
|
-
l = (
|
771
|
+
l = (a + n) % 3 == 0;
|
1058
772
|
break;
|
1059
773
|
case 4:
|
1060
|
-
l = (Math.floor(
|
774
|
+
l = (Math.floor(a / 3) + Math.floor(n / 2)) % 2 == 0;
|
1061
775
|
break;
|
1062
776
|
case 5:
|
1063
|
-
l =
|
777
|
+
l = a * n % 2 + a * n % 3 == 0;
|
1064
778
|
break;
|
1065
779
|
case 6:
|
1066
|
-
l = (
|
780
|
+
l = (a * n % 2 + a * n % 3) % 2 == 0;
|
1067
781
|
break;
|
1068
782
|
case 7:
|
1069
|
-
l = ((
|
783
|
+
l = ((a + n) % 2 + a * n % 3) % 2 == 0;
|
1070
784
|
break;
|
1071
785
|
default:
|
1072
786
|
throw new Error("Unreachable");
|
1073
787
|
}
|
1074
|
-
!this.isFunction[
|
788
|
+
!this.isFunction[n][a] && l && (this.modules[n][a] = !this.modules[n][a]);
|
1075
789
|
}
|
1076
790
|
}
|
1077
791
|
// Calculates and returns the penalty score based on state of this QR Code's current modules.
|
1078
792
|
// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
|
1079
793
|
getPenaltyScore() {
|
1080
|
-
let
|
1081
|
-
for (let
|
1082
|
-
let
|
1083
|
-
for (let
|
1084
|
-
this.modules[
|
1085
|
-
|
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;
|
1086
800
|
}
|
1087
|
-
for (let
|
1088
|
-
let
|
1089
|
-
for (let
|
1090
|
-
this.modules[
|
1091
|
-
|
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;
|
1092
806
|
}
|
1093
|
-
for (let
|
1094
|
-
for (let
|
1095
|
-
const
|
1096
|
-
|
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);
|
1097
811
|
}
|
1098
|
-
let
|
1099
|
-
for (const
|
1100
|
-
|
1101
|
-
const
|
1102
|
-
return
|
812
|
+
let n = 0;
|
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;
|
1103
817
|
}
|
1104
818
|
/*-- Private helper functions --*/
|
1105
819
|
// Returns an ascending list of positions of alignment patterns for this version number.
|
@@ -1109,86 +823,86 @@ var he;
|
|
1109
823
|
if (this.version == 1)
|
1110
824
|
return [];
|
1111
825
|
{
|
1112
|
-
const
|
1113
|
-
let
|
1114
|
-
for (let l = this.size - 7;
|
1115
|
-
|
1116
|
-
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;
|
1117
831
|
}
|
1118
832
|
}
|
1119
833
|
// Returns the number of data bits that can be stored in a QR Code of the given version number, after
|
1120
834
|
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
|
1121
835
|
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
|
1122
|
-
static getNumRawDataModules(
|
1123
|
-
if (
|
836
|
+
static getNumRawDataModules(r) {
|
837
|
+
if (r < E.MIN_VERSION || r > E.MAX_VERSION)
|
1124
838
|
throw new RangeError("Version number out of range");
|
1125
|
-
let
|
1126
|
-
if (
|
1127
|
-
const
|
1128
|
-
|
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);
|
1129
843
|
}
|
1130
|
-
return
|
844
|
+
return c(208 <= n && n <= 29648), n;
|
1131
845
|
}
|
1132
846
|
// Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
|
1133
847
|
// QR Code of the given version number and error correction level, with remainder bits discarded.
|
1134
848
|
// This stateless pure function could be implemented as a (40*4)-cell lookup table.
|
1135
|
-
static getNumDataCodewords(
|
1136
|
-
return Math.floor(
|
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];
|
1137
851
|
}
|
1138
852
|
// Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
|
1139
853
|
// implemented as a lookup table over all possible parameter values, instead of as an algorithm.
|
1140
|
-
static reedSolomonComputeDivisor(
|
1141
|
-
if (
|
854
|
+
static reedSolomonComputeDivisor(r) {
|
855
|
+
if (r < 1 || r > 255)
|
1142
856
|
throw new RangeError("Degree out of range");
|
1143
|
-
let
|
1144
|
-
for (let l = 0; l <
|
1145
|
-
|
1146
|
-
|
1147
|
-
let
|
1148
|
-
for (let l = 0; l <
|
1149
|
-
for (let
|
1150
|
-
|
1151
|
-
|
857
|
+
let n = [];
|
858
|
+
for (let l = 0; l < r - 1; l++)
|
859
|
+
n.push(0);
|
860
|
+
n.push(1);
|
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);
|
1152
866
|
}
|
1153
|
-
return
|
867
|
+
return n;
|
1154
868
|
}
|
1155
869
|
// Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
|
1156
|
-
static reedSolomonComputeRemainder(
|
1157
|
-
let
|
1158
|
-
for (const l of
|
1159
|
-
const
|
1160
|
-
|
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));
|
1161
875
|
}
|
1162
|
-
return
|
876
|
+
return a;
|
1163
877
|
}
|
1164
878
|
// Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
|
1165
879
|
// are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
|
1166
|
-
static reedSolomonMultiply(
|
1167
|
-
if (
|
880
|
+
static reedSolomonMultiply(r, n) {
|
881
|
+
if (r >>> 8 || n >>> 8)
|
1168
882
|
throw new RangeError("Byte out of range");
|
1169
|
-
let
|
883
|
+
let a = 0;
|
1170
884
|
for (let l = 7; l >= 0; l--)
|
1171
|
-
|
1172
|
-
return
|
885
|
+
a = a << 1 ^ (a >>> 7) * 285, a ^= (n >>> l & 1) * r;
|
886
|
+
return c(a >>> 8 == 0), a;
|
1173
887
|
}
|
1174
888
|
// Can only be called immediately after a light run is added, and
|
1175
889
|
// returns either 0, 1, or 2. A helper function for getPenaltyScore().
|
1176
|
-
finderPenaltyCountPatterns(
|
1177
|
-
const
|
1178
|
-
|
1179
|
-
const
|
1180
|
-
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);
|
1181
895
|
}
|
1182
896
|
// Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
|
1183
|
-
finderPenaltyTerminateAndCount(
|
1184
|
-
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);
|
1185
899
|
}
|
1186
900
|
// Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
|
1187
|
-
finderPenaltyAddHistory(
|
1188
|
-
|
901
|
+
finderPenaltyAddHistory(r, n) {
|
902
|
+
n[0] == 0 && (r += this.size), n.pop(), n.unshift(r);
|
1189
903
|
}
|
1190
904
|
};
|
1191
|
-
|
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 = [
|
1192
906
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
1193
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
|
1194
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],
|
@@ -1199,7 +913,7 @@ var he;
|
|
1199
913
|
// Quartile
|
1200
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]
|
1201
915
|
// High
|
1202
|
-
],
|
916
|
+
], t.NUM_ERROR_CORRECTION_BLOCKS = [
|
1203
917
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
1204
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
|
1205
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],
|
@@ -1210,95 +924,95 @@ var he;
|
|
1210
924
|
// Quartile
|
1211
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]
|
1212
926
|
// High
|
1213
|
-
],
|
1214
|
-
function
|
1215
|
-
if (
|
927
|
+
], s.QrCode = t;
|
928
|
+
function e(x, r, n) {
|
929
|
+
if (r < 0 || r > 31 || x >>> r)
|
1216
930
|
throw new RangeError("Value out of range");
|
1217
|
-
for (let
|
1218
|
-
|
931
|
+
for (let a = r - 1; a >= 0; a--)
|
932
|
+
n.push(x >>> a & 1);
|
1219
933
|
}
|
1220
|
-
function
|
1221
|
-
return (
|
934
|
+
function i(x, r) {
|
935
|
+
return (x >>> r & 1) != 0;
|
1222
936
|
}
|
1223
|
-
function
|
1224
|
-
if (!
|
937
|
+
function c(x) {
|
938
|
+
if (!x)
|
1225
939
|
throw new Error("Assertion error");
|
1226
940
|
}
|
1227
|
-
const
|
941
|
+
const u = class j {
|
1228
942
|
/*-- Constructor (low level) and fields --*/
|
1229
943
|
// Creates a new QR Code segment with the given attributes and data.
|
1230
944
|
// The character count (numChars) must agree with the mode and the bit buffer length,
|
1231
945
|
// but the constraint isn't checked. The given bit buffer is cloned and stored.
|
1232
|
-
constructor(
|
1233
|
-
if (this.mode =
|
946
|
+
constructor(r, n, a) {
|
947
|
+
if (this.mode = r, this.numChars = n, this.bitData = a, n < 0)
|
1234
948
|
throw new RangeError("Invalid argument");
|
1235
|
-
this.bitData =
|
949
|
+
this.bitData = a.slice();
|
1236
950
|
}
|
1237
951
|
/*-- Static factory functions (mid level) --*/
|
1238
952
|
// Returns a segment representing the given binary data encoded in
|
1239
953
|
// byte mode. All input byte arrays are acceptable. Any text string
|
1240
954
|
// can be converted to UTF-8 bytes and encoded as a byte mode segment.
|
1241
|
-
static makeBytes(
|
1242
|
-
let
|
1243
|
-
for (const
|
1244
|
-
|
1245
|
-
return new
|
955
|
+
static makeBytes(r) {
|
956
|
+
let n = [];
|
957
|
+
for (const a of r)
|
958
|
+
e(a, 8, n);
|
959
|
+
return new j(j.Mode.BYTE, r.length, n);
|
1246
960
|
}
|
1247
961
|
// Returns a segment representing the given string of decimal digits encoded in numeric mode.
|
1248
|
-
static makeNumeric(
|
1249
|
-
if (!
|
962
|
+
static makeNumeric(r) {
|
963
|
+
if (!j.isNumeric(r))
|
1250
964
|
throw new RangeError("String contains non-numeric characters");
|
1251
|
-
let
|
1252
|
-
for (let
|
1253
|
-
const l = Math.min(
|
1254
|
-
|
965
|
+
let n = [];
|
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;
|
1255
969
|
}
|
1256
|
-
return new
|
970
|
+
return new j(j.Mode.NUMERIC, r.length, n);
|
1257
971
|
}
|
1258
972
|
// Returns a segment representing the given text string encoded in alphanumeric mode.
|
1259
973
|
// The characters allowed are: 0 to 9, A to Z (uppercase only), space,
|
1260
974
|
// dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
1261
|
-
static makeAlphanumeric(
|
1262
|
-
if (!
|
975
|
+
static makeAlphanumeric(r) {
|
976
|
+
if (!j.isAlphanumeric(r))
|
1263
977
|
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
1264
|
-
let
|
1265
|
-
for (
|
1266
|
-
let l =
|
1267
|
-
l +=
|
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);
|
1268
982
|
}
|
1269
|
-
return
|
983
|
+
return a < r.length && e(j.ALPHANUMERIC_CHARSET.indexOf(r.charAt(a)), 6, n), new j(j.Mode.ALPHANUMERIC, r.length, n);
|
1270
984
|
}
|
1271
985
|
// Returns a new mutable list of zero or more segments to represent the given Unicode text string.
|
1272
986
|
// The result may use various segment modes and switch modes to optimize the length of the bit stream.
|
1273
|
-
static makeSegments(
|
1274
|
-
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))];
|
1275
989
|
}
|
1276
990
|
// Returns a segment representing an Extended Channel Interpretation
|
1277
991
|
// (ECI) designator with the given assignment value.
|
1278
|
-
static makeEci(
|
1279
|
-
let
|
1280
|
-
if (
|
992
|
+
static makeEci(r) {
|
993
|
+
let n = [];
|
994
|
+
if (r < 0)
|
1281
995
|
throw new RangeError("ECI assignment value out of range");
|
1282
|
-
if (
|
1283
|
-
|
1284
|
-
else if (
|
1285
|
-
|
1286
|
-
else if (
|
1287
|
-
|
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);
|
1288
1002
|
else
|
1289
1003
|
throw new RangeError("ECI assignment value out of range");
|
1290
|
-
return new
|
1004
|
+
return new j(j.Mode.ECI, 0, n);
|
1291
1005
|
}
|
1292
1006
|
// Tests whether the given string can be encoded as a segment in numeric mode.
|
1293
1007
|
// A string is encodable iff each character is in the range 0 to 9.
|
1294
|
-
static isNumeric(
|
1295
|
-
return
|
1008
|
+
static isNumeric(r) {
|
1009
|
+
return j.NUMERIC_REGEX.test(r);
|
1296
1010
|
}
|
1297
1011
|
// Tests whether the given string can be encoded as a segment in alphanumeric mode.
|
1298
1012
|
// A string is encodable iff each character is in the following set: 0 to 9, A to Z
|
1299
1013
|
// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
1300
|
-
static isAlphanumeric(
|
1301
|
-
return
|
1014
|
+
static isAlphanumeric(r) {
|
1015
|
+
return j.ALPHANUMERIC_REGEX.test(r);
|
1302
1016
|
}
|
1303
1017
|
/*-- Methods --*/
|
1304
1018
|
// Returns a new copy of the data bits of this segment.
|
@@ -1307,176 +1021,176 @@ var he;
|
|
1307
1021
|
}
|
1308
1022
|
// (Package-private) Calculates and returns the number of bits needed to encode the given segments at
|
1309
1023
|
// the given version. The result is infinity if a segment has too many characters to fit its length field.
|
1310
|
-
static getTotalBits(
|
1311
|
-
let
|
1312
|
-
for (const l of
|
1313
|
-
const
|
1314
|
-
if (l.numChars >= 1 <<
|
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)
|
1315
1029
|
return 1 / 0;
|
1316
|
-
|
1030
|
+
a += 4 + d + l.bitData.length;
|
1317
1031
|
}
|
1318
|
-
return
|
1032
|
+
return a;
|
1319
1033
|
}
|
1320
1034
|
// Returns a new array of bytes representing the given string encoded in UTF-8.
|
1321
|
-
static toUtf8ByteArray(
|
1322
|
-
|
1323
|
-
let
|
1324
|
-
for (let
|
1325
|
-
|
1326
|
-
return
|
1035
|
+
static toUtf8ByteArray(r) {
|
1036
|
+
r = encodeURI(r);
|
1037
|
+
let n = [];
|
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
|
+
return n;
|
1327
1041
|
}
|
1328
1042
|
};
|
1329
|
-
|
1330
|
-
let
|
1331
|
-
|
1332
|
-
})(
|
1333
|
-
((
|
1334
|
-
((
|
1335
|
-
const
|
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
|
+
})(K || (K = {}));
|
1047
|
+
((s) => {
|
1048
|
+
((t) => {
|
1049
|
+
const e = class {
|
1336
1050
|
// The QR Code can tolerate about 30% erroneous codewords
|
1337
1051
|
/*-- Constructor and fields --*/
|
1338
|
-
constructor(
|
1339
|
-
this.ordinal =
|
1052
|
+
constructor(c, u) {
|
1053
|
+
this.ordinal = c, this.formatBits = u;
|
1340
1054
|
}
|
1341
1055
|
};
|
1342
|
-
|
1343
|
-
})(
|
1344
|
-
})(
|
1345
|
-
((
|
1346
|
-
((
|
1347
|
-
const
|
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
|
+
})(s.QrCode || (s.QrCode = {}));
|
1058
|
+
})(K || (K = {}));
|
1059
|
+
((s) => {
|
1060
|
+
((t) => {
|
1061
|
+
const e = class {
|
1348
1062
|
/*-- Constructor and fields --*/
|
1349
|
-
constructor(
|
1350
|
-
this.modeBits =
|
1063
|
+
constructor(c, u) {
|
1064
|
+
this.modeBits = c, this.numBitsCharCount = u;
|
1351
1065
|
}
|
1352
1066
|
/*-- Method --*/
|
1353
1067
|
// (Package-private) Returns the bit width of the character count field for a segment in
|
1354
1068
|
// this mode in a QR Code at the given version number. The result is in the range [0, 16].
|
1355
|
-
numCharCountBits(
|
1356
|
-
return this.numBitsCharCount[Math.floor((
|
1069
|
+
numCharCountBits(c) {
|
1070
|
+
return this.numBitsCharCount[Math.floor((c + 7) / 17)];
|
1357
1071
|
}
|
1358
1072
|
};
|
1359
|
-
|
1360
|
-
})(
|
1361
|
-
})(
|
1362
|
-
var
|
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
|
+
})(s.QrSegment || (s.QrSegment = {}));
|
1075
|
+
})(K || (K = {}));
|
1076
|
+
var J = K;
|
1363
1077
|
/**
|
1364
1078
|
* @license qrcode.react
|
1365
1079
|
* Copyright (c) Paul O'Shannessy
|
1366
1080
|
* SPDX-License-Identifier: ISC
|
1367
1081
|
*/
|
1368
|
-
var
|
1369
|
-
L:
|
1370
|
-
M:
|
1371
|
-
Q:
|
1372
|
-
H:
|
1373
|
-
},
|
1374
|
-
function
|
1375
|
-
const
|
1376
|
-
return
|
1377
|
-
let
|
1378
|
-
|
1379
|
-
if (!
|
1380
|
-
|
1381
|
-
`M${
|
1382
|
-
),
|
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;
|
1383
1097
|
return;
|
1384
1098
|
}
|
1385
|
-
if (
|
1386
|
-
if (!
|
1099
|
+
if (x === i.length - 1) {
|
1100
|
+
if (!y)
|
1387
1101
|
return;
|
1388
|
-
|
1389
|
-
`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`
|
1390
1104
|
);
|
1391
1105
|
return;
|
1392
1106
|
}
|
1393
|
-
|
1107
|
+
y && u === null && (u = x);
|
1394
1108
|
});
|
1395
|
-
}),
|
1109
|
+
}), e.join("");
|
1396
1110
|
}
|
1397
|
-
function
|
1398
|
-
return
|
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));
|
1399
1113
|
}
|
1400
|
-
function
|
1401
|
-
if (
|
1114
|
+
function At(s, t, e, i) {
|
1115
|
+
if (i == null)
|
1402
1116
|
return null;
|
1403
|
-
const
|
1404
|
-
let
|
1405
|
-
if (
|
1406
|
-
let
|
1407
|
-
|
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 };
|
1408
1122
|
}
|
1409
|
-
const
|
1410
|
-
return { x:
|
1123
|
+
const g = i.crossOrigin;
|
1124
|
+
return { x: n, y: a, h: r, w: x, excavation: d, opacity: l, crossOrigin: g };
|
1411
1125
|
}
|
1412
|
-
function
|
1413
|
-
return
|
1126
|
+
function Ct(s, t) {
|
1127
|
+
return t != null ? Math.max(Math.floor(t), 0) : s ? vt : kt;
|
1414
1128
|
}
|
1415
|
-
function
|
1416
|
-
value:
|
1417
|
-
level:
|
1418
|
-
minVersion:
|
1419
|
-
includeMargin:
|
1420
|
-
marginSize:
|
1421
|
-
imageSettings:
|
1422
|
-
size:
|
1423
|
-
boostLevel:
|
1129
|
+
function Ue({
|
1130
|
+
value: s,
|
1131
|
+
level: t,
|
1132
|
+
minVersion: e,
|
1133
|
+
includeMargin: i,
|
1134
|
+
marginSize: c,
|
1135
|
+
imageSettings: u,
|
1136
|
+
size: y,
|
1137
|
+
boostLevel: x
|
1424
1138
|
}) {
|
1425
|
-
let
|
1426
|
-
const
|
1427
|
-
return
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
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,
|
1431
1145
|
void 0,
|
1432
1146
|
void 0,
|
1433
|
-
|
1147
|
+
x
|
1434
1148
|
);
|
1435
|
-
}, [
|
1436
|
-
const { cells:
|
1437
|
-
let
|
1438
|
-
const
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
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
|
+
y,
|
1155
|
+
h,
|
1156
|
+
u
|
1443
1157
|
);
|
1444
1158
|
return {
|
1445
|
-
cells:
|
1446
|
-
margin:
|
1447
|
-
numCells:
|
1448
|
-
calculatedImageSettings:
|
1159
|
+
cells: g,
|
1160
|
+
margin: h,
|
1161
|
+
numCells: m,
|
1162
|
+
calculatedImageSettings: f
|
1449
1163
|
};
|
1450
|
-
}, [
|
1164
|
+
}, [r, y, u, i, c]);
|
1451
1165
|
return {
|
1452
|
-
qrcode:
|
1453
|
-
margin:
|
1454
|
-
cells:
|
1166
|
+
qrcode: r,
|
1167
|
+
margin: a,
|
1168
|
+
cells: n,
|
1455
1169
|
numCells: l,
|
1456
|
-
calculatedImageSettings:
|
1170
|
+
calculatedImageSettings: d
|
1457
1171
|
};
|
1458
1172
|
}
|
1459
|
-
var
|
1173
|
+
var jt = function() {
|
1460
1174
|
try {
|
1461
1175
|
new Path2D().addPath(new Path2D());
|
1462
|
-
} catch (
|
1176
|
+
} catch (s) {
|
1463
1177
|
return !1;
|
1464
1178
|
}
|
1465
1179
|
return !0;
|
1466
|
-
}(),
|
1467
|
-
function(
|
1468
|
-
const
|
1469
|
-
value:
|
1470
|
-
size:
|
1471
|
-
level:
|
1472
|
-
bgColor:
|
1473
|
-
fgColor:
|
1474
|
-
includeMargin:
|
1475
|
-
minVersion:
|
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,
|
1476
1190
|
boostLevel: l,
|
1477
|
-
marginSize:
|
1478
|
-
imageSettings:
|
1479
|
-
} =
|
1191
|
+
marginSize: d,
|
1192
|
+
imageSettings: g
|
1193
|
+
} = i, m = ce(i, [
|
1480
1194
|
"value",
|
1481
1195
|
"size",
|
1482
1196
|
"level",
|
@@ -1487,92 +1201,92 @@ var xr = function() {
|
|
1487
1201
|
"boostLevel",
|
1488
1202
|
"marginSize",
|
1489
1203
|
"imageSettings"
|
1490
|
-
]), { style:
|
1491
|
-
(
|
1492
|
-
|
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
|
+
(W) => {
|
1206
|
+
p.current = W, typeof e == "function" ? e(W) : e && (e.current = W);
|
1493
1207
|
},
|
1494
|
-
[
|
1495
|
-
), [
|
1496
|
-
value:
|
1497
|
-
level:
|
1498
|
-
minVersion:
|
1208
|
+
[e]
|
1209
|
+
), [q, H] = L.useState(!1), { margin: O, cells: M, numCells: v, calculatedImageSettings: S } = Ue({
|
1210
|
+
value: c,
|
1211
|
+
level: y,
|
1212
|
+
minVersion: a,
|
1499
1213
|
boostLevel: l,
|
1500
|
-
includeMargin:
|
1501
|
-
marginSize:
|
1502
|
-
imageSettings:
|
1503
|
-
size:
|
1214
|
+
includeMargin: n,
|
1215
|
+
marginSize: d,
|
1216
|
+
imageSettings: g,
|
1217
|
+
size: u
|
1504
1218
|
});
|
1505
|
-
|
1506
|
-
if (
|
1507
|
-
const
|
1508
|
-
if (!
|
1219
|
+
L.useEffect(() => {
|
1220
|
+
if (p.current != null) {
|
1221
|
+
const W = p.current, I = W.getContext("2d");
|
1222
|
+
if (!I)
|
1509
1223
|
return;
|
1510
|
-
let
|
1511
|
-
const
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
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
|
1515
1229
|
));
|
1516
|
-
const
|
1517
|
-
|
1518
|
-
const
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1230
|
+
const X = window.devicePixelRatio || 1;
|
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);
|
1522
1236
|
});
|
1523
|
-
}),
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1237
|
+
}), S && (I.globalAlpha = S.opacity), te && I.drawImage(
|
1238
|
+
$,
|
1239
|
+
S.x + O,
|
1240
|
+
S.y + O,
|
1241
|
+
S.w,
|
1242
|
+
S.h
|
1529
1243
|
);
|
1530
1244
|
}
|
1531
|
-
}),
|
1532
|
-
|
1533
|
-
}, [
|
1534
|
-
const
|
1535
|
-
let
|
1536
|
-
return
|
1245
|
+
}), L.useEffect(() => {
|
1246
|
+
H(!1);
|
1247
|
+
}, [w]);
|
1248
|
+
const B = le({ height: u, width: u }, f);
|
1249
|
+
let ee = null;
|
1250
|
+
return w != null && (ee = /* @__PURE__ */ L.createElement(
|
1537
1251
|
"img",
|
1538
1252
|
{
|
1539
|
-
src:
|
1540
|
-
key:
|
1253
|
+
src: w,
|
1254
|
+
key: w,
|
1541
1255
|
style: { display: "none" },
|
1542
1256
|
onLoad: () => {
|
1543
|
-
|
1257
|
+
H(!0);
|
1544
1258
|
},
|
1545
|
-
ref:
|
1546
|
-
crossOrigin:
|
1259
|
+
ref: T,
|
1260
|
+
crossOrigin: S == null ? void 0 : S.crossOrigin
|
1547
1261
|
}
|
1548
|
-
)), /* @__PURE__ */
|
1262
|
+
)), /* @__PURE__ */ L.createElement(L.Fragment, null, /* @__PURE__ */ L.createElement(
|
1549
1263
|
"canvas",
|
1550
|
-
|
1551
|
-
style:
|
1552
|
-
height:
|
1553
|
-
width:
|
1554
|
-
ref:
|
1264
|
+
le({
|
1265
|
+
style: B,
|
1266
|
+
height: u,
|
1267
|
+
width: u,
|
1268
|
+
ref: C,
|
1555
1269
|
role: "img"
|
1556
|
-
},
|
1557
|
-
),
|
1270
|
+
}, k)
|
1271
|
+
), ee);
|
1558
1272
|
}
|
1559
1273
|
);
|
1560
|
-
|
1561
|
-
var
|
1562
|
-
function(
|
1563
|
-
const
|
1564
|
-
value:
|
1565
|
-
size:
|
1566
|
-
level:
|
1567
|
-
bgColor:
|
1568
|
-
fgColor:
|
1569
|
-
includeMargin:
|
1570
|
-
minVersion:
|
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,
|
1571
1285
|
boostLevel: l,
|
1572
|
-
title:
|
1573
|
-
marginSize:
|
1574
|
-
imageSettings:
|
1575
|
-
} =
|
1286
|
+
title: d,
|
1287
|
+
marginSize: g,
|
1288
|
+
imageSettings: h
|
1289
|
+
} = i, m = ce(i, [
|
1576
1290
|
"value",
|
1577
1291
|
"size",
|
1578
1292
|
"level",
|
@@ -1584,126 +1298,230 @@ var At = B.forwardRef(
|
|
1584
1298
|
"title",
|
1585
1299
|
"marginSize",
|
1586
1300
|
"imageSettings"
|
1587
|
-
]), { margin:
|
1588
|
-
value:
|
1589
|
-
level:
|
1590
|
-
minVersion:
|
1301
|
+
]), { margin: f, cells: k, numCells: w, calculatedImageSettings: p } = Ue({
|
1302
|
+
value: c,
|
1303
|
+
level: y,
|
1304
|
+
minVersion: a,
|
1591
1305
|
boostLevel: l,
|
1592
|
-
includeMargin:
|
1593
|
-
marginSize:
|
1594
|
-
imageSettings:
|
1595
|
-
size:
|
1306
|
+
includeMargin: n,
|
1307
|
+
marginSize: g,
|
1308
|
+
imageSettings: h,
|
1309
|
+
size: u
|
1596
1310
|
});
|
1597
|
-
let
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
)),
|
1311
|
+
let T = k, C = null;
|
1312
|
+
h != null && p != null && (p.excavation != null && (T = De(
|
1313
|
+
k,
|
1314
|
+
p.excavation
|
1315
|
+
)), C = /* @__PURE__ */ L.createElement(
|
1602
1316
|
"image",
|
1603
1317
|
{
|
1604
|
-
href:
|
1605
|
-
height:
|
1606
|
-
width:
|
1607
|
-
x:
|
1608
|
-
y:
|
1318
|
+
href: h.src,
|
1319
|
+
height: p.h,
|
1320
|
+
width: p.w,
|
1321
|
+
x: p.x + f,
|
1322
|
+
y: p.y + f,
|
1609
1323
|
preserveAspectRatio: "none",
|
1610
|
-
opacity:
|
1611
|
-
crossOrigin:
|
1324
|
+
opacity: p.opacity,
|
1325
|
+
crossOrigin: p.crossOrigin
|
1612
1326
|
}
|
1613
1327
|
));
|
1614
|
-
const
|
1615
|
-
return /* @__PURE__ */
|
1328
|
+
const q = Pe(T, f);
|
1329
|
+
return /* @__PURE__ */ L.createElement(
|
1616
1330
|
"svg",
|
1617
|
-
|
1618
|
-
height:
|
1619
|
-
width:
|
1620
|
-
viewBox: `0 0 ${
|
1621
|
-
ref:
|
1331
|
+
le({
|
1332
|
+
height: u,
|
1333
|
+
width: u,
|
1334
|
+
viewBox: `0 0 ${w} ${w}`,
|
1335
|
+
ref: e,
|
1622
1336
|
role: "img"
|
1623
|
-
},
|
1624
|
-
!!
|
1625
|
-
/* @__PURE__ */
|
1337
|
+
}, m),
|
1338
|
+
!!d && /* @__PURE__ */ L.createElement("title", null, d),
|
1339
|
+
/* @__PURE__ */ L.createElement(
|
1626
1340
|
"path",
|
1627
1341
|
{
|
1628
|
-
fill:
|
1629
|
-
d: `M0,0 h${
|
1342
|
+
fill: x,
|
1343
|
+
d: `M0,0 h${w}v${w}H0z`,
|
1630
1344
|
shapeRendering: "crispEdges"
|
1631
1345
|
}
|
1632
1346
|
),
|
1633
|
-
/* @__PURE__ */
|
1634
|
-
|
1347
|
+
/* @__PURE__ */ L.createElement("path", { fill: r, d: q, shapeRendering: "crispEdges" }),
|
1348
|
+
C
|
1635
1349
|
);
|
1636
1350
|
}
|
1637
1351
|
);
|
1638
|
-
|
1639
|
-
const
|
1640
|
-
walletAddress:
|
1641
|
-
amount:
|
1642
|
-
currency:
|
1643
|
-
|
1644
|
-
|
1352
|
+
Oe.displayName = "QRCodeSVG";
|
1353
|
+
const Rt = ({
|
1354
|
+
walletAddress: s,
|
1355
|
+
amount: t,
|
1356
|
+
currency: e,
|
1357
|
+
network: i,
|
1358
|
+
theme: c = "light",
|
1359
|
+
size: u = 200
|
1645
1360
|
}) => {
|
1646
|
-
const [
|
1647
|
-
|
1648
|
-
if (!
|
1649
|
-
|
1361
|
+
const [y, x] = D(""), [r, n] = D(null);
|
1362
|
+
Z(() => {
|
1363
|
+
if (!s || s === "No address configured") {
|
1364
|
+
n("No wallet address configured for this network");
|
1650
1365
|
return;
|
1651
1366
|
}
|
1652
1367
|
try {
|
1653
|
-
let
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
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,
|
1670
1435
|
{
|
1671
|
-
value:
|
1672
|
-
size:
|
1673
|
-
bgColor:
|
1674
|
-
fgColor:
|
1436
|
+
value: y,
|
1437
|
+
size: u,
|
1438
|
+
bgColor: c === "dark" ? "#374151" : "#FFFFFF",
|
1439
|
+
fgColor: c === "dark" ? "#FFFFFF" : "#000000",
|
1675
1440
|
level: "H",
|
1676
1441
|
includeMargin: !0
|
1677
1442
|
}
|
1678
1443
|
) }),
|
1679
|
-
/* @__PURE__ */
|
1680
|
-
/* @__PURE__ */
|
1681
|
-
|
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
|
+
] })
|
1682
1455
|
] }),
|
1683
|
-
/* @__PURE__ */
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
/* @__PURE__ */ i.jsx("li", { children: "2. Scan the QR code above" }),
|
1689
|
-
/* @__PURE__ */ i.jsxs("li", { children: [
|
1690
|
-
"3. Confirm the payment amount (",
|
1691
|
-
a,
|
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: [
|
1460
|
+
t,
|
1692
1461
|
" ",
|
1693
|
-
|
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(", "),
|
1694
1494
|
")"
|
1695
1495
|
] }),
|
1696
|
-
/* @__PURE__ */
|
1697
|
-
|
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
|
+
] }) })
|
1698
1516
|
] }) })
|
1699
1517
|
] });
|
1700
|
-
},
|
1701
|
-
const
|
1702
|
-
switch (
|
1518
|
+
}, ie = ({ status: s, message: t, theme: e = "light" }) => {
|
1519
|
+
const i = () => {
|
1520
|
+
switch (s) {
|
1703
1521
|
case "processing":
|
1704
|
-
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" });
|
1705
1523
|
case "success":
|
1706
|
-
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(
|
1707
1525
|
"svg",
|
1708
1526
|
{
|
1709
1527
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -1712,11 +1530,11 @@ const Kr = ({
|
|
1712
1530
|
viewBox: "0 0 24 24",
|
1713
1531
|
stroke: "currentColor",
|
1714
1532
|
strokeWidth: 2,
|
1715
|
-
children: /* @__PURE__ */
|
1533
|
+
children: /* @__PURE__ */ o.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
|
1716
1534
|
}
|
1717
1535
|
) });
|
1718
1536
|
case "error":
|
1719
|
-
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(
|
1720
1538
|
"svg",
|
1721
1539
|
{
|
1722
1540
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -1725,14 +1543,14 @@ const Kr = ({
|
|
1725
1543
|
viewBox: "0 0 24 24",
|
1726
1544
|
stroke: "currentColor",
|
1727
1545
|
strokeWidth: 2,
|
1728
|
-
children: /* @__PURE__ */
|
1546
|
+
children: /* @__PURE__ */ o.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
1729
1547
|
}
|
1730
1548
|
) });
|
1731
1549
|
default:
|
1732
1550
|
return null;
|
1733
1551
|
}
|
1734
|
-
},
|
1735
|
-
switch (
|
1552
|
+
}, c = () => {
|
1553
|
+
switch (s) {
|
1736
1554
|
case "processing":
|
1737
1555
|
return "Processing Payment";
|
1738
1556
|
case "success":
|
@@ -1742,622 +1560,499 @@ const Kr = ({
|
|
1742
1560
|
default:
|
1743
1561
|
return "Unknown Status";
|
1744
1562
|
}
|
1745
|
-
},
|
1746
|
-
switch (
|
1563
|
+
}, u = () => {
|
1564
|
+
switch (s) {
|
1747
1565
|
case "processing":
|
1748
|
-
return
|
1566
|
+
return e === "dark" ? "text-blue-300" : "text-blue-600";
|
1749
1567
|
case "success":
|
1750
|
-
return
|
1568
|
+
return e === "dark" ? "text-green-300" : "text-green-600";
|
1751
1569
|
case "error":
|
1752
|
-
return
|
1570
|
+
return e === "dark" ? "text-red-300" : "text-red-600";
|
1753
1571
|
default:
|
1754
|
-
return
|
1572
|
+
return e === "dark" ? "text-gray-300" : "text-gray-600";
|
1755
1573
|
}
|
1756
1574
|
};
|
1757
|
-
return /* @__PURE__ */
|
1758
|
-
/* @__PURE__ */
|
1759
|
-
/* @__PURE__ */
|
1760
|
-
/* @__PURE__ */
|
1761
|
-
|
1762
|
-
|
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." }) })
|
1763
1581
|
] });
|
1764
|
-
},
|
1765
|
-
ETHEREUM
|
1766
|
-
|
1767
|
-
|
1768
|
-
ALGORAND: "algorand"
|
1769
|
-
}, C = {
|
1770
|
-
METAMASK: "metamask",
|
1771
|
-
TRONLINK: "tronlink",
|
1772
|
-
TRUST_WALLET: "trust_wallet",
|
1773
|
-
LUTE: "lute"
|
1774
|
-
}, Ge = {
|
1775
|
-
[k.ETHEREUM]: {
|
1776
|
-
chainId: "0x1",
|
1777
|
-
chainName: "Ethereum Mainnet",
|
1778
|
-
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
1779
|
-
rpcUrls: ["https://mainnet.infura.io/v3/"],
|
1780
|
-
blockExplorerUrls: ["https://etherscan.io/"],
|
1781
|
-
supportedWallets: [C.METAMASK, C.TRUST_WALLET]
|
1782
|
-
},
|
1783
|
-
[k.BSC]: {
|
1784
|
-
chainId: "0x38",
|
1785
|
-
chainName: "BNB Smart Chain",
|
1786
|
-
nativeCurrency: { name: "BNB", symbol: "BNB", decimals: 18 },
|
1787
|
-
rpcUrls: ["https://bsc-dataseed.binance.org/"],
|
1788
|
-
blockExplorerUrls: ["https://bscscan.com/"],
|
1789
|
-
supportedWallets: [C.METAMASK, C.TRUST_WALLET]
|
1790
|
-
},
|
1791
|
-
[k.TRON]: {
|
1792
|
-
fullHost: "https://api.trongrid.io",
|
1793
|
-
explorerUrl: "https://tronscan.org",
|
1794
|
-
supportedWallets: [C.TRONLINK]
|
1795
|
-
},
|
1796
|
-
[k.ALGORAND]: {
|
1797
|
-
network: "mainnet",
|
1798
|
-
explorerUrl: "https://algoexplorer.io",
|
1799
|
-
supportedWallets: [C.LUTE]
|
1800
|
-
}
|
1801
|
-
}, br = {
|
1802
|
-
USDT: {
|
1803
|
-
[k.ETHEREUM]: {
|
1804
|
-
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
1805
|
-
decimals: 6
|
1806
|
-
},
|
1807
|
-
[k.BSC]: {
|
1808
|
-
address: "0x55d398326f99059fF775485246999027B3197955",
|
1809
|
-
decimals: 18
|
1810
|
-
},
|
1811
|
-
[k.TRON]: {
|
1812
|
-
address: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
1813
|
-
decimals: 6
|
1814
|
-
}
|
1815
|
-
},
|
1816
|
-
USDC: {
|
1817
|
-
[k.ETHEREUM]: {
|
1818
|
-
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
1819
|
-
decimals: 6
|
1820
|
-
},
|
1821
|
-
[k.BSC]: {
|
1822
|
-
address: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
|
1823
|
-
decimals: 18
|
1824
|
-
},
|
1825
|
-
[k.TRON]: {
|
1826
|
-
address: "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",
|
1827
|
-
decimals: 6
|
1828
|
-
}
|
1829
|
-
},
|
1830
|
-
ALGO: {
|
1831
|
-
[k.ALGORAND]: {
|
1832
|
-
address: "native",
|
1833
|
-
decimals: 6
|
1834
|
-
}
|
1835
|
-
}
|
1836
|
-
};
|
1837
|
-
let ke = null;
|
1838
|
-
const Nr = () => G(void 0, null, function* () {
|
1839
|
-
if (ke)
|
1840
|
-
return ke;
|
1841
|
-
try {
|
1842
|
-
const o = yield import("web3");
|
1843
|
-
return ke = o.default || o, ke;
|
1844
|
-
} catch (o) {
|
1845
|
-
throw console.error("Failed to import Web3:", o), new Error("Web3 is required for EVM transactions. Please install web3 package.");
|
1846
|
-
}
|
1847
|
-
}), He = () => {
|
1848
|
-
const o = {
|
1849
|
-
[C.METAMASK]: !1,
|
1850
|
-
[C.TRUST_WALLET]: !1,
|
1851
|
-
[C.TRONLINK]: !1,
|
1852
|
-
[C.LUTE]: !1
|
1853
|
-
};
|
1854
|
-
return typeof window != "undefined" && (o[C.METAMASK] = !!(window.ethereum && window.ethereum.isMetaMask), o[C.TRONLINK] = !!(window.tronWeb && window.tronWeb.ready), o[C.TRUST_WALLET] = !!(window.ethereum && window.ethereum.isTrust), o[C.LUTE] = !!(window.algorand && window.algorand.isLute)), o;
|
1855
|
-
}, jt = (o) => {
|
1856
|
-
const a = Ge[o];
|
1857
|
-
if (!a)
|
1858
|
-
return [];
|
1859
|
-
const n = He();
|
1860
|
-
return a.supportedWallets.filter((d) => n[d]);
|
1861
|
-
}, Rr = (o, a) => G(void 0, null, function* () {
|
1862
|
-
switch (o) {
|
1863
|
-
case C.METAMASK:
|
1864
|
-
return yield Tr(a);
|
1865
|
-
case C.TRONLINK:
|
1866
|
-
return yield Cr();
|
1867
|
-
case C.TRUST_WALLET:
|
1868
|
-
return yield Ar(a);
|
1869
|
-
case C.LUTE:
|
1870
|
-
return yield jr();
|
1871
|
-
default:
|
1872
|
-
throw new Error(`Unsupported wallet type: ${o}`);
|
1873
|
-
}
|
1874
|
-
}), Tr = (o) => G(void 0, null, function* () {
|
1875
|
-
if (!window.ethereum || !window.ethereum.isMetaMask)
|
1876
|
-
throw new Error("MetaMask is not installed");
|
1877
|
-
try {
|
1878
|
-
const a = yield window.ethereum.request({
|
1879
|
-
method: "eth_requestAccounts"
|
1880
|
-
}), n = Ge[o];
|
1881
|
-
return n && n.chainId && (yield St(n)), {
|
1882
|
-
address: a[0],
|
1883
|
-
network: o,
|
1884
|
-
walletType: C.METAMASK
|
1885
|
-
};
|
1886
|
-
} catch (a) {
|
1887
|
-
throw new Error(`Failed to connect MetaMask: ${a.message}`);
|
1888
|
-
}
|
1889
|
-
}), Cr = () => G(void 0, null, function* () {
|
1890
|
-
if (!window.tronWeb)
|
1891
|
-
throw new Error("TronLink is not installed");
|
1892
|
-
let o = 0;
|
1893
|
-
for (; !window.tronWeb.ready && o < 10; )
|
1894
|
-
yield new Promise((n) => setTimeout(n, 1e3)), o++;
|
1895
|
-
if (!window.tronWeb.ready)
|
1896
|
-
throw new Error("Please unlock your TronLink wallet");
|
1897
|
-
const a = window.tronWeb.defaultAddress.base58;
|
1898
|
-
if (!a)
|
1899
|
-
throw new Error("No account found in TronLink");
|
1900
|
-
return {
|
1901
|
-
address: a,
|
1902
|
-
network: k.TRON,
|
1903
|
-
walletType: C.TRONLINK
|
1904
|
-
};
|
1905
|
-
}), Ar = (o) => G(void 0, null, function* () {
|
1906
|
-
if (!window.ethereum || !window.ethereum.isTrust)
|
1907
|
-
throw new Error("Trust Wallet is not installed");
|
1908
|
-
try {
|
1909
|
-
const a = yield window.ethereum.request({
|
1910
|
-
method: "eth_requestAccounts"
|
1911
|
-
}), n = Ge[o];
|
1912
|
-
return n && n.chainId && (yield St(n)), {
|
1913
|
-
address: a[0],
|
1914
|
-
network: o,
|
1915
|
-
walletType: C.TRUST_WALLET
|
1916
|
-
};
|
1917
|
-
} catch (a) {
|
1918
|
-
throw new Error(`Failed to connect Trust Wallet: ${a.message}`);
|
1919
|
-
}
|
1920
|
-
}), jr = () => G(void 0, null, function* () {
|
1921
|
-
if (!window.algorand || !window.algorand.isLute)
|
1922
|
-
throw new Error("Lute wallet is not installed");
|
1923
|
-
try {
|
1924
|
-
return {
|
1925
|
-
address: (yield window.algorand.connect())[0],
|
1926
|
-
network: k.ALGORAND,
|
1927
|
-
walletType: C.LUTE
|
1928
|
-
};
|
1929
|
-
} catch (o) {
|
1930
|
-
throw new Error(`Failed to connect Lute wallet: ${o.message}`);
|
1931
|
-
}
|
1932
|
-
}), St = (o) => G(void 0, null, function* () {
|
1933
|
-
try {
|
1934
|
-
yield window.ethereum.request({
|
1935
|
-
method: "wallet_switchEthereumChain",
|
1936
|
-
params: [{ chainId: o.chainId }]
|
1937
|
-
});
|
1938
|
-
} catch (a) {
|
1939
|
-
if (a.code === 4902)
|
1940
|
-
yield window.ethereum.request({
|
1941
|
-
method: "wallet_addEthereumChain",
|
1942
|
-
params: [o]
|
1943
|
-
});
|
1944
|
-
else
|
1945
|
-
throw a;
|
1946
|
-
}
|
1947
|
-
}), Sr = (o, a) => G(void 0, null, function* () {
|
1948
|
-
const { walletType: n, network: d, address: h } = o, { to: m, amount: b, tokenAddress: y, tokenDecimals: t } = a;
|
1949
|
-
switch (n) {
|
1950
|
-
case C.METAMASK:
|
1951
|
-
case C.TRUST_WALLET:
|
1952
|
-
return yield kr(h, m, b, y, t);
|
1953
|
-
case C.TRONLINK:
|
1954
|
-
return yield Mr(m, b, y, t);
|
1955
|
-
case C.LUTE:
|
1956
|
-
return yield Pr(h, m, b);
|
1957
|
-
default:
|
1958
|
-
throw new Error(`Unsupported wallet type: ${n}`);
|
1959
|
-
}
|
1960
|
-
}), kr = (o, a, n, d, h) => G(void 0, null, function* () {
|
1961
|
-
const m = yield Nr();
|
1962
|
-
if (!window.ethereum)
|
1963
|
-
throw new Error("No Ethereum provider found");
|
1964
|
-
const b = new m(window.ethereum), y = b.utils.toBN(
|
1965
|
-
Math.floor(parseFloat(n) * Math.pow(10, h || 18))
|
1966
|
-
);
|
1967
|
-
if (d && d !== "native") {
|
1968
|
-
const t = [
|
1969
|
-
{
|
1970
|
-
constant: !1,
|
1971
|
-
inputs: [
|
1972
|
-
{ name: "_to", type: "address" },
|
1973
|
-
{ name: "_value", type: "uint256" }
|
1974
|
-
],
|
1975
|
-
name: "transfer",
|
1976
|
-
outputs: [{ name: "", type: "bool" }],
|
1977
|
-
payable: !1,
|
1978
|
-
stateMutability: "nonpayable",
|
1979
|
-
type: "function"
|
1980
|
-
}
|
1981
|
-
];
|
1982
|
-
return (yield new b.eth.Contract(t, d).methods.transfer(a, y).send({ from: o })).transactionHash;
|
1983
|
-
} else
|
1984
|
-
return (yield b.eth.sendTransaction({
|
1985
|
-
from: o,
|
1986
|
-
to: a,
|
1987
|
-
value: y
|
1988
|
-
})).transactionHash;
|
1989
|
-
}), Mr = (o, a, n, d) => G(void 0, null, function* () {
|
1990
|
-
if (!window.tronWeb || !window.tronWeb.ready)
|
1991
|
-
throw new Error("TronLink is not ready");
|
1992
|
-
const h = Math.floor(parseFloat(a) * Math.pow(10, d || 6));
|
1993
|
-
return n && n !== "native" ? yield (yield window.tronWeb.contract().at(n)).transfer(o, h).send({
|
1994
|
-
feeLimit: 1e8,
|
1995
|
-
callValue: 0
|
1996
|
-
}) : (yield window.tronWeb.trx.sendTransaction(o, h)).txid;
|
1997
|
-
}), Pr = (o, a, n) => G(void 0, null, function* () {
|
1998
|
-
if (!window.algorand)
|
1999
|
-
throw new Error("Lute wallet is not available");
|
2000
|
-
const d = Math.floor(parseFloat(n) * 1e6), h = {
|
2001
|
-
from: o,
|
2002
|
-
to: a,
|
2003
|
-
amount: d,
|
2004
|
-
type: "pay"
|
2005
|
-
}, m = yield window.algorand.signTransaction(h);
|
2006
|
-
return (yield window.algorand.sendTransaction(m)).txId;
|
2007
|
-
}), Or = (o) => ({
|
2008
|
-
[C.METAMASK]: "https://metamask.io/",
|
2009
|
-
[C.TRONLINK]: "https://www.tronlink.org/",
|
2010
|
-
[C.TRUST_WALLET]: "https://trustwallet.com/",
|
2011
|
-
[C.LUTE]: "https://lute.app/"
|
2012
|
-
})[o] || "", Lr = ({ onSelect: o, selected: a, theme: n = "light", supportedNetworks: d = [] }) => {
|
2013
|
-
const [h, m] = H({}), [b, y] = H(k.ETHEREUM);
|
2014
|
-
je(() => {
|
2015
|
-
m(He());
|
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);
|
1584
|
+
Z(() => {
|
1585
|
+
x(ue());
|
2016
1586
|
}, []);
|
2017
|
-
const
|
2018
|
-
{
|
2019
|
-
id: "USDT",
|
2020
|
-
name: "USDT",
|
2021
|
-
description: "Tether USD",
|
2022
|
-
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",
|
2023
|
-
networks: [k.ETHEREUM, k.BSC, k.TRON]
|
2024
|
-
},
|
1587
|
+
const a = [
|
2025
1588
|
{
|
2026
|
-
id:
|
2027
|
-
name: "
|
2028
|
-
description: "
|
2029
|
-
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",
|
2030
|
-
networks: [k.ETHEREUM, k.BSC, k.TRON]
|
1589
|
+
id: b.ETHEREUM,
|
1590
|
+
name: "Ethereum",
|
1591
|
+
description: "ERC-20 tokens"
|
2031
1592
|
},
|
2032
1593
|
{
|
2033
|
-
id:
|
2034
|
-
name: "
|
2035
|
-
description: "
|
2036
|
-
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",
|
2037
|
-
networks: [k.BSC]
|
1594
|
+
id: b.BSC,
|
1595
|
+
name: "BSC (Binance Smart Chain)",
|
1596
|
+
description: "BEP-20 tokens"
|
2038
1597
|
},
|
2039
1598
|
{
|
2040
|
-
id:
|
2041
|
-
name: "
|
2042
|
-
description: "
|
2043
|
-
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",
|
2044
|
-
networks: [k.ETHEREUM]
|
1599
|
+
id: b.TRON,
|
1600
|
+
name: "Tron",
|
1601
|
+
description: "TRC-20 tokens"
|
2045
1602
|
},
|
2046
1603
|
{
|
2047
|
-
id:
|
2048
|
-
name: "
|
2049
|
-
description: "
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
{
|
2054
|
-
|
2055
|
-
|
2056
|
-
description: "Algorand",
|
2057
|
-
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR0Yx1Vp8qPQI5XZoJuKfQS8bj_FNiMZGCHqA&s",
|
2058
|
-
networks: [k.ALGORAND]
|
2059
|
-
}
|
2060
|
-
], s = t.filter((u) => d.length === 0 ? !0 : u.networks.some((p) => d.includes(p))), r = (u) => {
|
2061
|
-
const p = t.find((v) => v.id === u);
|
2062
|
-
return p ? p.networks : [];
|
2063
|
-
}, l = (u) => ({
|
2064
|
-
[k.ETHEREUM]: "Ethereum",
|
2065
|
-
[k.BSC]: "BSC",
|
2066
|
-
[k.TRON]: "Tron",
|
2067
|
-
[k.ALGORAND]: "Algorand"
|
2068
|
-
})[u] || u, c = (u) => jt(u).length > 0, w = (u, p) => {
|
2069
|
-
var v;
|
2070
|
-
y(p), o({
|
2071
|
-
currency: u,
|
2072
|
-
network: p,
|
2073
|
-
tokenConfig: (v = br[u]) == null ? void 0 : v[p]
|
2074
|
-
});
|
2075
|
-
};
|
2076
|
-
return /* @__PURE__ */ i.jsxs("div", { children: [
|
2077
|
-
/* @__PURE__ */ i.jsx("h3", { className: `text-lg font-medium mb-3 ${n === "dark" ? "text-white" : "text-gray-800"}`, children: "Select Payment Method" }),
|
2078
|
-
/* @__PURE__ */ i.jsx("div", { className: "space-y-3", children: s.map((u) => {
|
2079
|
-
const p = r(u.id), v = (a == null ? void 0 : a.currency) === u.id;
|
2080
|
-
return /* @__PURE__ */ i.jsxs("div", { className: "space-y-2", children: [
|
2081
|
-
/* @__PURE__ */ i.jsxs("div", { className: `flex items-center p-3 rounded-lg border-2 transition-colors ${v ? n === "dark" ? "bg-blue-900/30 border-[#7042D2]" : "bg-blue-50 border-[#7042D2]" : n === "dark" ? "bg-gray-700 border-gray-700" : "bg-white border-gray-200"}`, children: [
|
2082
|
-
/* @__PURE__ */ i.jsx("div", { className: "flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mr-3", children: /* @__PURE__ */ i.jsx("img", { src: u.logo, alt: u.name, className: "h-6 w-6" }) }),
|
2083
|
-
/* @__PURE__ */ i.jsxs("div", { className: "flex-1", children: [
|
2084
|
-
/* @__PURE__ */ i.jsx("h4", { className: `font-medium ${n === "dark" ? "text-white" : "text-gray-900"}`, children: u.name }),
|
2085
|
-
/* @__PURE__ */ i.jsx("p", { className: `text-sm ${n === "dark" ? "text-gray-300" : "text-gray-500"}`, children: u.description })
|
2086
|
-
] })
|
2087
|
-
] }),
|
2088
|
-
p.length > 1 && /* @__PURE__ */ i.jsxs("div", { className: "ml-4 space-y-2", children: [
|
2089
|
-
/* @__PURE__ */ i.jsx("p", { className: `text-sm font-medium ${n === "dark" ? "text-gray-300" : "text-gray-700"}`, children: "Select Network:" }),
|
2090
|
-
/* @__PURE__ */ i.jsx("div", { className: "grid grid-cols-2 gap-2", children: p.map((T) => {
|
2091
|
-
const N = v && (a == null ? void 0 : a.network) === T, x = c(T);
|
2092
|
-
return /* @__PURE__ */ i.jsx(
|
2093
|
-
"button",
|
2094
|
-
{
|
2095
|
-
onClick: () => w(u.id, T),
|
2096
|
-
disabled: !x,
|
2097
|
-
className: `p-2 rounded-md text-sm font-medium transition-colors ${N ? "bg-[#7042D2] text-white" : x ? n === "dark" ? "bg-gray-600 text-gray-200 hover:bg-gray-500" : "bg-gray-100 text-gray-700 hover:bg-gray-200" : n === "dark" ? "bg-gray-800 text-gray-500 cursor-not-allowed" : "bg-gray-50 text-gray-400 cursor-not-allowed"}`,
|
2098
|
-
children: /* @__PURE__ */ i.jsxs("div", { className: "flex items-center justify-center space-x-1", children: [
|
2099
|
-
/* @__PURE__ */ i.jsx("span", { children: l(T) }),
|
2100
|
-
!x && /* @__PURE__ */ i.jsx("span", { className: "text-xs", children: "(No wallet)" })
|
2101
|
-
] })
|
2102
|
-
},
|
2103
|
-
T
|
2104
|
-
);
|
2105
|
-
}) })
|
2106
|
-
] }),
|
2107
|
-
p.length === 1 && /* @__PURE__ */ i.jsx("div", { className: "ml-4", children: /* @__PURE__ */ i.jsx(
|
2108
|
-
"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(
|
2109
1613
|
{
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
}
|
2130
|
-
)
|
2131
|
-
}
|
2132
|
-
)
|
2133
|
-
] })
|
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
|
2134
1633
|
}
|
2135
|
-
)
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
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
|
+
] }) })
|
2145
1775
|
] });
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
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 = ({
|
1798
|
+
isOpen: s,
|
1799
|
+
onClose: t,
|
1800
|
+
payment: e,
|
1801
|
+
paymentStatus: i,
|
1802
|
+
selectedPaymentMethod: c,
|
1803
|
+
onPaymentMethodSelect: u,
|
1804
|
+
onPayment: y,
|
1805
|
+
onBack: x,
|
1806
|
+
error: r,
|
1807
|
+
theme: n = "light",
|
1808
|
+
merchantName: a,
|
2158
1809
|
transactionHash: l,
|
2159
|
-
walletConnection:
|
2160
|
-
onConnectWallet:
|
2161
|
-
testMode:
|
2162
|
-
supportedNetworks:
|
2163
|
-
availableWallets:
|
2164
|
-
supportedWallets:
|
2165
|
-
step:
|
1810
|
+
walletConnection: d,
|
1811
|
+
onConnectWallet: g,
|
1812
|
+
testMode: h = !1,
|
1813
|
+
supportedNetworks: m = [],
|
1814
|
+
availableWallets: f = {},
|
1815
|
+
supportedWallets: k = [],
|
1816
|
+
step: w = "select-currency"
|
2166
1817
|
}) => {
|
2167
|
-
const
|
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) => ({
|
2168
1819
|
ethereum: "Ethereum",
|
2169
1820
|
bsc: "BSC",
|
2170
1821
|
tron: "Tron",
|
2171
1822
|
algorand: "Algorand"
|
2172
|
-
})[
|
2173
|
-
[
|
2174
|
-
[
|
2175
|
-
[
|
2176
|
-
[
|
2177
|
-
})[
|
2178
|
-
[
|
2179
|
-
[
|
2180
|
-
[
|
2181
|
-
[
|
2182
|
-
})[
|
2183
|
-
return
|
2184
|
-
/* @__PURE__ */
|
2185
|
-
/* @__PURE__ */
|
2186
|
-
/* @__PURE__ */
|
1823
|
+
})[v] || v, O = (v) => ({
|
1824
|
+
[N.METAMASK]: "MetaMask",
|
1825
|
+
[N.TRONLINK]: "TronLink",
|
1826
|
+
[N.TRUST_WALLET]: "Trust Wallet",
|
1827
|
+
[N.LUTE]: "Lute Wallet"
|
1828
|
+
})[v] || v, M = (v) => ({
|
1829
|
+
[N.METAMASK]: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",
|
1830
|
+
[N.TRONLINK]: "https://www.tronlink.org/images/logo.png",
|
1831
|
+
[N.TRUST_WALLET]: "https://trustwallet.com/assets/images/trust_logotype.svg",
|
1832
|
+
[N.LUTE]: "https://lute.app/logo.png"
|
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(
|
2187
1838
|
"button",
|
2188
1839
|
{
|
2189
|
-
onClick:
|
1840
|
+
onClick: t,
|
2190
1841
|
className: "text-gray-500 hover:text-gray-700 focus:outline-none",
|
2191
|
-
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" }) })
|
2192
1843
|
}
|
2193
1844
|
)
|
2194
1845
|
] }),
|
2195
|
-
/* @__PURE__ */
|
2196
|
-
|
2197
|
-
/* @__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: [
|
2198
1849
|
"PAY: ",
|
2199
|
-
|
1850
|
+
a
|
2200
1851
|
] }),
|
2201
|
-
/* @__PURE__ */
|
2202
|
-
/* @__PURE__ */
|
2203
|
-
/* @__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: [
|
2204
1855
|
"$",
|
2205
|
-
|
1856
|
+
C(e.totalAmount || e.amount)
|
2206
1857
|
] })
|
2207
1858
|
] }),
|
2208
|
-
/* @__PURE__ */
|
1859
|
+
/* @__PURE__ */ o.jsx("div", { className: "text-xs mt-1 text-right", children: /* @__PURE__ */ o.jsxs("span", { className: "text-gray-500", children: [
|
2209
1860
|
"Payment ID: ",
|
2210
|
-
|
1861
|
+
e.id ? e.id.slice(0, 8) : "",
|
2211
1862
|
"..."
|
2212
1863
|
] }) })
|
2213
1864
|
] }),
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
2218
|
-
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
2224
|
-
/* @__PURE__ */
|
2225
|
-
|
2226
|
-
|
2227
|
-
|
2228
|
-
|
2229
|
-
|
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 })
|
2230
1896
|
] }),
|
2231
|
-
/* @__PURE__ */
|
2232
|
-
/* @__PURE__ */
|
2233
|
-
/* @__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) })
|
2234
1900
|
] }),
|
2235
|
-
/* @__PURE__ */
|
2236
|
-
/* @__PURE__ */
|
2237
|
-
/* @__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%" })
|
2238
1904
|
] })
|
2239
1905
|
] })
|
2240
1906
|
] }),
|
2241
|
-
|
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 ? (
|
2242
1926
|
// Test mode payment option
|
2243
|
-
/* @__PURE__ */
|
2244
|
-
/* @__PURE__ */
|
2245
|
-
/* @__PURE__ */
|
2246
|
-
/* @__PURE__ */
|
2247
|
-
/* @__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' })
|
2248
1932
|
] })
|
2249
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
|
+
) })
|
2250
1946
|
) : (
|
2251
|
-
//
|
2252
|
-
/* @__PURE__ */
|
2253
|
-
/* @__PURE__ */
|
2254
|
-
|
2255
|
-
/* @__PURE__ */
|
2256
|
-
|
2257
|
-
/* @__PURE__ */
|
2258
|
-
/* @__PURE__ */ i.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: [
|
2259
1954
|
"No wallets detected for ",
|
2260
|
-
|
1955
|
+
H(c.network),
|
2261
1956
|
" network"
|
2262
1957
|
] })
|
2263
1958
|
] })
|
2264
|
-
] }) }) :
|
2265
|
-
/* @__PURE__ */
|
2266
|
-
/* @__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(
|
2267
1962
|
"img",
|
2268
1963
|
{
|
2269
|
-
src:
|
2270
|
-
alt:
|
2271
|
-
className: "w-8 h-8 mr-
|
2272
|
-
onError: (
|
2273
|
-
|
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";
|
2274
1969
|
}
|
2275
1970
|
}
|
2276
1971
|
),
|
2277
|
-
/* @__PURE__ */
|
2278
|
-
/* @__PURE__ */
|
2279
|
-
/* @__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: [
|
2280
1975
|
"Pay with ",
|
2281
|
-
|
1976
|
+
O(v)
|
2282
1977
|
] })
|
2283
1978
|
] })
|
2284
1979
|
] }),
|
2285
|
-
(
|
2286
|
-
/* @__PURE__ */
|
2287
|
-
/* @__PURE__ */
|
2288
|
-
] }) : /* @__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(
|
2289
1984
|
"button",
|
2290
1985
|
{
|
2291
|
-
onClick: () =>
|
2292
|
-
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",
|
2293
1988
|
children: "Connect"
|
2294
1989
|
}
|
2295
1990
|
)
|
2296
|
-
] }) },
|
2297
|
-
/* @__PURE__ */
|
2298
|
-
/* @__PURE__ */
|
2299
|
-
|
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),
|
2300
1995
|
" not detected"
|
2301
1996
|
] }),
|
2302
|
-
/* @__PURE__ */
|
1997
|
+
/* @__PURE__ */ o.jsx(
|
2303
1998
|
"a",
|
2304
1999
|
{
|
2305
|
-
href:
|
2000
|
+
href: ct(v),
|
2306
2001
|
target: "_blank",
|
2307
2002
|
rel: "noopener noreferrer",
|
2308
2003
|
className: "text-sm text-[#7042D2] hover:underline",
|
2309
2004
|
children: "Install"
|
2310
2005
|
}
|
2311
2006
|
)
|
2312
|
-
] }) },
|
2007
|
+
] }) }, v)) })
|
2313
2008
|
] })
|
2314
2009
|
),
|
2315
|
-
/* @__PURE__ */
|
2316
|
-
/* @__PURE__ */
|
2010
|
+
/* @__PURE__ */ o.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
|
2011
|
+
/* @__PURE__ */ o.jsx(
|
2317
2012
|
"button",
|
2318
2013
|
{
|
2319
2014
|
type: "button",
|
2320
|
-
onClick:
|
2015
|
+
onClick: x,
|
2321
2016
|
className: "w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",
|
2322
2017
|
children: "Back"
|
2323
2018
|
}
|
2324
2019
|
),
|
2325
|
-
/* @__PURE__ */
|
2020
|
+
/* @__PURE__ */ o.jsx(
|
2326
2021
|
"button",
|
2327
2022
|
{
|
2328
2023
|
type: "button",
|
2329
|
-
onClick:
|
2024
|
+
onClick: () => y(p === "qrcode"),
|
2330
2025
|
className: "w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",
|
2331
|
-
disabled: !
|
2332
|
-
children: "Pay Now"
|
2026
|
+
disabled: !h && p === "wallet" && !d,
|
2027
|
+
children: p === "qrcode" ? "I have sent the payment" : "Pay Now"
|
2333
2028
|
}
|
2334
2029
|
)
|
2335
2030
|
] })
|
2336
2031
|
] }),
|
2337
|
-
|
2338
|
-
|
2032
|
+
w === "processing" && /* @__PURE__ */ o.jsx(
|
2033
|
+
ie,
|
2339
2034
|
{
|
2340
2035
|
status: "processing",
|
2341
|
-
theme:
|
2036
|
+
theme: n,
|
2342
2037
|
message: "Processing your payment..."
|
2343
2038
|
}
|
2344
2039
|
),
|
2345
|
-
|
2346
|
-
/* @__PURE__ */
|
2347
|
-
|
2040
|
+
w === "success" && /* @__PURE__ */ o.jsxs("div", { children: [
|
2041
|
+
/* @__PURE__ */ o.jsx(
|
2042
|
+
ie,
|
2348
2043
|
{
|
2349
2044
|
status: "success",
|
2350
|
-
theme:
|
2045
|
+
theme: n,
|
2351
2046
|
message: "Payment successful!"
|
2352
2047
|
}
|
2353
2048
|
),
|
2354
|
-
l && /* @__PURE__ */
|
2355
|
-
/* @__PURE__ */
|
2356
|
-
/* @__PURE__ */
|
2357
|
-
|
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(
|
2358
2053
|
"a",
|
2359
2054
|
{
|
2360
|
-
href: `${
|
2055
|
+
href: `${Dt(c.network)}/${Ut(c.network)}/${l}`,
|
2361
2056
|
target: "_blank",
|
2362
2057
|
rel: "noopener noreferrer",
|
2363
2058
|
className: "text-xs text-[#7042D2] mt-2 inline-block",
|
@@ -2366,207 +2061,225 @@ const Nr = () => G(void 0, null, function* () {
|
|
2366
2061
|
)
|
2367
2062
|
] })
|
2368
2063
|
] }),
|
2369
|
-
|
2370
|
-
/* @__PURE__ */
|
2371
|
-
|
2064
|
+
w === "error" && /* @__PURE__ */ o.jsxs("div", { children: [
|
2065
|
+
/* @__PURE__ */ o.jsx(
|
2066
|
+
ie,
|
2372
2067
|
{
|
2373
2068
|
status: "error",
|
2374
|
-
theme:
|
2375
|
-
message:
|
2069
|
+
theme: n,
|
2070
|
+
message: r || "An error occurred while processing your payment."
|
2376
2071
|
}
|
2377
2072
|
),
|
2378
|
-
/* @__PURE__ */
|
2073
|
+
/* @__PURE__ */ o.jsx(
|
2379
2074
|
"button",
|
2380
2075
|
{
|
2381
2076
|
type: "button",
|
2382
|
-
onClick:
|
2077
|
+
onClick: x,
|
2383
2078
|
className: "mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",
|
2384
2079
|
children: "Try Again"
|
2385
2080
|
}
|
2386
2081
|
)
|
2387
2082
|
] })
|
2388
2083
|
] }),
|
2389
|
-
/* @__PURE__ */
|
2084
|
+
/* @__PURE__ */ o.jsx("div", { className: "text-center text-xs text-gray-500", children: /* @__PURE__ */ o.jsxs("p", { children: [
|
2390
2085
|
"Powered by ",
|
2391
|
-
/* @__PURE__ */
|
2086
|
+
/* @__PURE__ */ o.jsx("span", { className: "text-[#7042D2]", children: "Coinley" }),
|
2392
2087
|
" - Secure Cryptocurrency Payments"
|
2393
2088
|
] }) })
|
2394
2089
|
] }) }) }) : null;
|
2395
|
-
},
|
2090
|
+
}, Dt = (s) => ({
|
2396
2091
|
ethereum: "https://etherscan.io",
|
2397
2092
|
bsc: "https://bscscan.com",
|
2398
2093
|
tron: "https://tronscan.org",
|
2399
2094
|
algorand: "https://algoexplorer.io"
|
2400
|
-
})[
|
2401
|
-
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2095
|
+
})[s] || "https://etherscan.io", Ut = (s) => ({
|
2096
|
+
ethereum: "tx",
|
2097
|
+
bsc: "tx",
|
2098
|
+
tron: "transaction",
|
2099
|
+
algorand: "tx"
|
2100
|
+
})[s] || "tx", Ot = _e(({
|
2101
|
+
apiKey: s,
|
2102
|
+
apiSecret: t,
|
2103
|
+
apiUrl: e,
|
2104
|
+
customerEmail: i,
|
2105
|
+
merchantName: c = "Merchant",
|
2106
|
+
merchantWalletAddresses: u = {},
|
2407
2107
|
// Object with network-specific addresses
|
2408
|
-
onSuccess:
|
2409
|
-
onError:
|
2410
|
-
onClose:
|
2411
|
-
theme:
|
2412
|
-
autoOpen:
|
2108
|
+
onSuccess: y,
|
2109
|
+
onError: x,
|
2110
|
+
onClose: r,
|
2111
|
+
theme: n,
|
2112
|
+
autoOpen: a = !1,
|
2413
2113
|
debug: l = !1,
|
2414
|
-
testMode:
|
2415
|
-
supportedNetworks:
|
2114
|
+
testMode: d = !1,
|
2115
|
+
supportedNetworks: g = [],
|
2416
2116
|
// Array of supported networks
|
2417
|
-
preferredNetwork:
|
2418
|
-
preferredWallet:
|
2419
|
-
},
|
2420
|
-
const
|
2421
|
-
|
2422
|
-
const
|
2423
|
-
|
2424
|
-
open: (
|
2425
|
-
|
2117
|
+
preferredNetwork: h = b.ETHEREUM,
|
2118
|
+
preferredWallet: m = N.METAMASK
|
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);
|
2426
2126
|
},
|
2427
2127
|
close: () => {
|
2428
|
-
|
2128
|
+
he();
|
2429
2129
|
},
|
2430
|
-
getPayment: () =>
|
2431
|
-
getWalletConnection: () =>
|
2130
|
+
getPayment: () => C,
|
2131
|
+
getWalletConnection: () => I
|
2432
2132
|
}));
|
2433
|
-
const
|
2434
|
-
|
2133
|
+
const P = (A, F) => {
|
2134
|
+
re && console.log(`[Coinley SDK] ${A}`, F);
|
2435
2135
|
};
|
2436
|
-
|
2136
|
+
Z(() => {
|
2437
2137
|
if (typeof window != "undefined") {
|
2438
|
-
const
|
2439
|
-
|
2138
|
+
const A = ue();
|
2139
|
+
te(A), P("Available wallets detected:", A);
|
2440
2140
|
}
|
2441
|
-
}, [
|
2442
|
-
const
|
2443
|
-
if (!
|
2444
|
-
|
2141
|
+
}, [re]);
|
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"));
|
2445
2145
|
return;
|
2446
2146
|
}
|
2447
|
-
|
2147
|
+
O("loading"), T(!0), G("select-currency");
|
2448
2148
|
try {
|
2449
|
-
|
2450
|
-
const
|
2451
|
-
amount:
|
2452
|
-
currency:
|
2453
|
-
network:
|
2454
|
-
customerEmail:
|
2455
|
-
callbackUrl:
|
2456
|
-
metadata:
|
2457
|
-
merchantWalletAddresses:
|
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)
|
2458
2158
|
});
|
2459
|
-
|
2460
|
-
} catch (
|
2461
|
-
|
2462
|
-
}
|
2463
|
-
}),
|
2464
|
-
|
2465
|
-
},
|
2466
|
-
|
2467
|
-
},
|
2468
|
-
|
2469
|
-
},
|
2470
|
-
if (!
|
2471
|
-
|
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);
|
2162
|
+
}
|
2163
|
+
}), he = () => {
|
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) {
|
2171
|
+
B("Please select a payment method first");
|
2472
2172
|
return;
|
2473
2173
|
}
|
2474
2174
|
try {
|
2475
|
-
|
2476
|
-
const
|
2477
|
-
|
2478
|
-
} catch (
|
2479
|
-
|
2480
|
-
}
|
2481
|
-
}),
|
2482
|
-
var
|
2483
|
-
if (!
|
2484
|
-
|
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) {
|
2184
|
+
B("Missing payment information");
|
2485
2185
|
return;
|
2486
2186
|
}
|
2487
|
-
if (!
|
2488
|
-
|
2187
|
+
if (!I && !d) {
|
2188
|
+
B("Please connect your wallet first");
|
2489
2189
|
return;
|
2490
2190
|
}
|
2491
|
-
|
2191
|
+
P("Starting payment process..."), O("loading"), W(null);
|
2492
2192
|
try {
|
2493
|
-
let
|
2494
|
-
if (
|
2495
|
-
|
2193
|
+
let Q;
|
2194
|
+
if (d)
|
2195
|
+
P("Test mode: Generating mock transaction..."), Q = `test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2, 10)}`;
|
2496
2196
|
else {
|
2497
|
-
const
|
2498
|
-
if (!
|
2499
|
-
throw new Error(`No merchant wallet address configured for ${
|
2500
|
-
|
2501
|
-
to:
|
2502
|
-
amount:
|
2503
|
-
tokenAddress: (
|
2504
|
-
tokenDecimals: (
|
2197
|
+
const me = u[M.network];
|
2198
|
+
if (!me)
|
2199
|
+
throw new Error(`No merchant wallet address configured for ${M.network}`);
|
2200
|
+
P("Sending transaction through wallet..."), Q = yield ot(I, {
|
2201
|
+
to: me,
|
2202
|
+
amount: C.amount,
|
2203
|
+
tokenAddress: (A = M.tokenConfig) == null ? void 0 : A.address,
|
2204
|
+
tokenDecimals: (F = M.tokenConfig) == null ? void 0 : F.decimals
|
2505
2205
|
});
|
2506
2206
|
}
|
2507
|
-
|
2508
|
-
const
|
2509
|
-
paymentId:
|
2510
|
-
transactionHash:
|
2511
|
-
network:
|
2512
|
-
currency:
|
2513
|
-
senderAddress:
|
2207
|
+
P("Transaction hash:", Q), W(Q), P("Processing payment with backend...");
|
2208
|
+
const Ge = yield ht({
|
2209
|
+
paymentId: C.id,
|
2210
|
+
transactionHash: Q,
|
2211
|
+
network: M.network,
|
2212
|
+
currency: M.currency,
|
2213
|
+
senderAddress: I == null ? void 0 : I.address
|
2514
2214
|
});
|
2515
|
-
|
2516
|
-
network:
|
2517
|
-
currency:
|
2518
|
-
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
|
2519
2219
|
}));
|
2520
|
-
} catch (
|
2521
|
-
|
2220
|
+
} catch (Q) {
|
2221
|
+
P("Payment error:", Q), B(Q.message || "Failed to process payment"), O("error"), G("error"), x && x(Q);
|
2522
2222
|
}
|
2523
|
-
}),
|
2524
|
-
return /* @__PURE__ */
|
2525
|
-
|
2223
|
+
}), ze = () => M ? Ze(M.network) : [];
|
2224
|
+
return /* @__PURE__ */ o.jsx(o.Fragment, { children: p && /* @__PURE__ */ o.jsx(
|
2225
|
+
Pt,
|
2526
2226
|
{
|
2527
|
-
isOpen:
|
2528
|
-
onClose:
|
2529
|
-
payment:
|
2530
|
-
paymentStatus:
|
2531
|
-
selectedPaymentMethod:
|
2532
|
-
onPaymentMethodSelect:
|
2533
|
-
onPayment:
|
2534
|
-
onBack:
|
2535
|
-
error:
|
2536
|
-
theme:
|
2537
|
-
merchantName:
|
2538
|
-
transactionHash:
|
2539
|
-
walletConnection:
|
2540
|
-
onConnectWallet:
|
2541
|
-
testMode:
|
2542
|
-
supportedNetworks:
|
2543
|
-
availableWallets:
|
2544
|
-
supportedWallets:
|
2545
|
-
step:
|
2227
|
+
isOpen: p,
|
2228
|
+
onClose: he,
|
2229
|
+
payment: C,
|
2230
|
+
paymentStatus: H,
|
2231
|
+
selectedPaymentMethod: M,
|
2232
|
+
onPaymentMethodSelect: Fe,
|
2233
|
+
onPayment: Qe,
|
2234
|
+
onBack: Be,
|
2235
|
+
error: S,
|
2236
|
+
theme: oe,
|
2237
|
+
merchantName: c,
|
2238
|
+
transactionHash: ee,
|
2239
|
+
walletConnection: I,
|
2240
|
+
onConnectWallet: We,
|
2241
|
+
testMode: d,
|
2242
|
+
supportedNetworks: ae,
|
2243
|
+
availableWallets: $,
|
2244
|
+
supportedWallets: ze(),
|
2245
|
+
step: X
|
2546
2246
|
}
|
2547
2247
|
) });
|
2548
2248
|
});
|
2549
|
-
|
2550
|
-
const
|
2551
|
-
apiUrl: "
|
2249
|
+
Ot.displayName = "CoinleyCheckout";
|
2250
|
+
const Vt = {
|
2251
|
+
apiUrl: "http://localhost:9000",
|
2552
2252
|
debug: !1,
|
2553
2253
|
testMode: !1,
|
2554
|
-
theme: "light"
|
2555
|
-
|
2254
|
+
theme: "light",
|
2255
|
+
supportedNetworks: ["ethereum", "bsc", "tron", "algorand"]
|
2256
|
+
}, _t = "0.3.2";
|
2556
2257
|
export {
|
2557
|
-
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2258
|
+
Ot as CoinleyCheckout,
|
2259
|
+
Pt as CoinleyModal,
|
2260
|
+
Ht as CoinleyProvider,
|
2261
|
+
Vt as DEFAULT_CONFIG,
|
2262
|
+
de as NETWORK_CONFIG,
|
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,
|
2270
|
+
N as WALLET_TYPES,
|
2271
|
+
et as connectWallet,
|
2272
|
+
ut as createPayment,
|
2273
|
+
ue as detectWallets,
|
2274
|
+
Gt as generateMockTransactionHash,
|
2275
|
+
Qt as getMerchantProfile,
|
2276
|
+
Bt as getPayment,
|
2277
|
+
Wt as getSupportedNetworks,
|
2278
|
+
Ze as getSupportedWalletsForNetwork,
|
2279
|
+
ct as getWalletInstallUrl,
|
2280
|
+
ht as processPayment,
|
2281
|
+
ot as sendTransaction,
|
2282
|
+
bt as useCoinley,
|
2283
|
+
zt as validateWalletAddress
|
2571
2284
|
};
|
2572
2285
|
//# sourceMappingURL=coinley-checkout.es.js.map
|