coinley-checkout 0.3.0 → 0.3.1
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 +1369 -1890
- 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/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 Ke = Object.defineProperty, Ve = Object.defineProperties;
|
2
|
+
var qe = Object.getOwnPropertyDescriptors;
|
3
|
+
var fe = Object.getOwnPropertySymbols;
|
4
|
+
var $e = Object.prototype.hasOwnProperty, _e = Object.prototype.propertyIsEnumerable;
|
5
|
+
var ge = (s, r, t) => r in s ? Ke(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t, z = (s, r) => {
|
6
|
+
for (var t in r || (r = {}))
|
7
|
+
$e.call(r, t) && ge(s, t, r[t]);
|
8
|
+
if (fe)
|
9
|
+
for (var t of fe(r))
|
10
|
+
_e.call(r, t) && ge(s, t, r[t]);
|
11
|
+
return s;
|
12
|
+
}, we = (s, r) => Ve(s, qe(r));
|
13
|
+
var R = (s, r, t) => new Promise((c, u) => {
|
14
|
+
var h = (e) => {
|
15
15
|
try {
|
16
|
-
|
17
|
-
} catch (
|
18
|
-
|
16
|
+
w(t.next(e));
|
17
|
+
} catch (n) {
|
18
|
+
u(n);
|
19
19
|
}
|
20
|
-
},
|
20
|
+
}, y = (e) => {
|
21
21
|
try {
|
22
|
-
|
23
|
-
} catch (
|
24
|
-
|
22
|
+
w(t.throw(e));
|
23
|
+
} catch (n) {
|
24
|
+
u(n);
|
25
25
|
}
|
26
|
-
},
|
27
|
-
|
26
|
+
}, w = (e) => e.done ? c(e.value) : Promise.resolve(e.value).then(h, y);
|
27
|
+
w((t = t.apply(s, r)).next());
|
28
28
|
});
|
29
|
-
import
|
30
|
-
|
29
|
+
import S, { createContext as ye, useContext as xe, useState as U, useEffect as Z, forwardRef as Ye, useImperativeHandle as Je } from "react";
|
30
|
+
const A = {
|
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
|
+
[A.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
|
+
[A.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
|
+
[A.TRON]: {
|
58
|
+
fullHost: "https://api.trongrid.io",
|
59
|
+
explorerUrl: "https://tronscan.org",
|
60
|
+
supportedWallets: [N.TRONLINK]
|
61
|
+
},
|
62
|
+
[A.ALGORAND]: {
|
63
|
+
network: "mainnet",
|
64
|
+
explorerUrl: "https://algoexplorer.io",
|
65
|
+
supportedWallets: [N.LUTE]
|
66
|
+
}
|
67
|
+
}, Xe = {
|
68
|
+
USDT: {
|
69
|
+
[A.ETHEREUM]: {
|
70
|
+
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
71
|
+
decimals: 6
|
72
|
+
},
|
73
|
+
[A.BSC]: {
|
74
|
+
address: "0x55d398326f99059fF775485246999027B3197955",
|
75
|
+
decimals: 18
|
76
|
+
},
|
77
|
+
[A.TRON]: {
|
78
|
+
address: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
79
|
+
decimals: 6
|
80
|
+
}
|
81
|
+
},
|
82
|
+
USDC: {
|
83
|
+
[A.ETHEREUM]: {
|
84
|
+
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
85
|
+
decimals: 6
|
86
|
+
},
|
87
|
+
[A.BSC]: {
|
88
|
+
address: "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",
|
89
|
+
decimals: 18
|
90
|
+
},
|
91
|
+
[A.TRON]: {
|
92
|
+
address: "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",
|
93
|
+
decimals: 6
|
94
|
+
}
|
95
|
+
},
|
96
|
+
ALGO: {
|
97
|
+
[A.ALGORAND]: {
|
98
|
+
address: "native",
|
99
|
+
decimals: 6
|
100
|
+
}
|
101
|
+
}
|
102
|
+
};
|
103
|
+
let _ = null;
|
104
|
+
const Ze = () => 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 (r) {
|
127
|
+
console.warn("Error detecting wallets:", r);
|
128
|
+
}
|
129
|
+
return s;
|
130
|
+
}, Ne = (s) => {
|
131
|
+
const r = de[s];
|
132
|
+
if (!r)
|
133
|
+
return [];
|
134
|
+
const t = ue();
|
135
|
+
return r.supportedWallets.filter((c) => t[c]);
|
136
|
+
}, et = (s, r) => R(void 0, null, function* () {
|
137
|
+
switch (s) {
|
138
|
+
case N.METAMASK:
|
139
|
+
return yield tt(r);
|
140
|
+
case N.TRONLINK:
|
141
|
+
return yield rt();
|
142
|
+
case N.TRUST_WALLET:
|
143
|
+
return yield st(r);
|
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 r = yield window.ethereum.request({
|
154
|
+
method: "eth_requestAccounts"
|
155
|
+
});
|
156
|
+
if (!r || r.length === 0)
|
157
|
+
throw new Error("No accounts found. Please unlock MetaMask.");
|
158
|
+
const t = de[s];
|
159
|
+
return t && t.chainId && (yield Ee(t)), {
|
160
|
+
address: r[0],
|
161
|
+
network: s,
|
162
|
+
walletType: N.METAMASK
|
163
|
+
};
|
164
|
+
} catch (r) {
|
165
|
+
throw r.code === 4001 ? new Error("User rejected the connection request") : new Error(`Failed to connect MetaMask: ${r.message}`);
|
166
|
+
}
|
167
|
+
}), rt = () => R(void 0, null, function* () {
|
168
|
+
var c;
|
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 r = 10;
|
173
|
+
for (; !window.tronWeb.ready && s < r; )
|
174
|
+
yield new Promise((u) => setTimeout(u, 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 t = (c = window.tronWeb.defaultAddress) == null ? void 0 : c.base58;
|
178
|
+
if (!t)
|
179
|
+
throw new Error("No account found in TronLink. Please make sure you have an account set up.");
|
180
|
+
return {
|
181
|
+
address: t,
|
182
|
+
network: A.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 r = yield window.ethereum.request({
|
190
|
+
method: "eth_requestAccounts"
|
191
|
+
});
|
192
|
+
if (!r || r.length === 0)
|
193
|
+
throw new Error("No accounts found. Please unlock Trust Wallet.");
|
194
|
+
const t = de[s];
|
195
|
+
return t && t.chainId && (yield Ee(t)), {
|
196
|
+
address: r[0],
|
197
|
+
network: s,
|
198
|
+
walletType: N.TRUST_WALLET
|
199
|
+
};
|
200
|
+
} catch (r) {
|
201
|
+
throw r.code === 4001 ? new Error("User rejected the connection request") : new Error(`Failed to connect Trust Wallet: ${r.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: A.ALGORAND,
|
213
|
+
walletType: N.LUTE
|
214
|
+
};
|
215
|
+
} catch (s) {
|
216
|
+
throw new Error(`Failed to connect Lute wallet: ${s.message}`);
|
217
|
+
}
|
218
|
+
}), Ee = (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 (r) {
|
227
|
+
if (r.code === 4902)
|
228
|
+
try {
|
229
|
+
yield window.ethereum.request({
|
230
|
+
method: "wallet_addEthereumChain",
|
231
|
+
params: [s]
|
232
|
+
});
|
233
|
+
} catch (t) {
|
234
|
+
throw new Error(`Failed to add ${s.chainName} to wallet: ${t.message}`);
|
235
|
+
}
|
236
|
+
else
|
237
|
+
throw r.code === 4001 ? new Error("User rejected network switch request") : new Error(`Failed to switch to ${s.chainName}: ${r.message}`);
|
238
|
+
}
|
239
|
+
}), ot = (s, r) => R(void 0, null, function* () {
|
240
|
+
const { walletType: t, network: c, address: u } = s, { to: h, amount: y, tokenAddress: w, tokenDecimals: e } = r;
|
241
|
+
switch (t) {
|
242
|
+
case N.METAMASK:
|
243
|
+
case N.TRUST_WALLET:
|
244
|
+
return yield at(u, h, y, w, e);
|
245
|
+
case N.TRONLINK:
|
246
|
+
return yield lt(h, y, w, e);
|
247
|
+
case N.LUTE:
|
248
|
+
return yield it(u, h, y);
|
249
|
+
default:
|
250
|
+
throw new Error(`Unsupported wallet type: ${t}`);
|
251
|
+
}
|
252
|
+
}), at = (s, r, t, c, u) => R(void 0, null, function* () {
|
253
|
+
if (typeof window == "undefined" || !window.ethereum)
|
254
|
+
throw new Error("Ethereum provider not found");
|
255
|
+
try {
|
256
|
+
const h = yield Ze(), y = new h(window.ethereum), w = y.utils.toBN(
|
257
|
+
Math.floor(parseFloat(t) * Math.pow(10, u || 18))
|
258
|
+
);
|
259
|
+
if (c && c !== "native") {
|
260
|
+
const e = [
|
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(e, c).methods.transfer(r, w).send({ from: s })).transactionHash;
|
275
|
+
} else
|
276
|
+
return (yield y.eth.sendTransaction({
|
277
|
+
from: s,
|
278
|
+
to: r,
|
279
|
+
value: w
|
280
|
+
})).transactionHash;
|
281
|
+
} catch (h) {
|
282
|
+
throw h.code === 4001 ? new Error("Transaction was rejected by user") : new Error(`Transaction failed: ${h.message}`);
|
283
|
+
}
|
284
|
+
}), lt = (s, r, t, c) => 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 u = Math.floor(parseFloat(r) * Math.pow(10, c || 6));
|
289
|
+
return t && t !== "native" ? yield (yield window.tronWeb.contract().at(t)).transfer(s, u).send({
|
290
|
+
feeLimit: 1e8,
|
291
|
+
callValue: 0
|
292
|
+
}) : (yield window.tronWeb.trx.sendTransaction(s, u)).txid;
|
293
|
+
} catch (u) {
|
294
|
+
throw new Error(`TRON transaction failed: ${u.message}`);
|
295
|
+
}
|
296
|
+
}), it = (s, r, t) => 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 c = Math.floor(parseFloat(t) * 1e6), u = {
|
301
|
+
from: s,
|
302
|
+
to: r,
|
303
|
+
amount: c,
|
304
|
+
type: "pay"
|
305
|
+
}, h = yield window.algorand.signTransaction(u);
|
306
|
+
return (yield window.algorand.sendTransaction(h)).txId;
|
307
|
+
} catch (c) {
|
308
|
+
throw new Error(`Algorand transaction failed: ${c.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 P = {
|
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
|
+
P = z(z({}, P), s), console.log("API initialized with:", {
|
325
|
+
apiUrl: P.apiUrl,
|
326
|
+
apiKey: P.apiKey ? `${P.apiKey.substring(0, 6)}...` : null,
|
327
|
+
hasWalletAddresses: Object.keys(P.merchantWalletAddresses || {}).length > 0
|
42
328
|
});
|
43
|
-
},
|
329
|
+
}, J = () => ({
|
44
330
|
"Content-Type": "application/json",
|
45
|
-
"x-api-key":
|
46
|
-
"x-api-secret":
|
47
|
-
}),
|
331
|
+
"x-api-key": P.apiKey,
|
332
|
+
"x-api-secret": P.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:", `${P.apiUrl}/api/payments/create`);
|
336
|
+
const r = we(z({}, s), {
|
337
|
+
merchantWalletAddresses: z(z({}, P.merchantWalletAddresses), s.merchantWalletAddresses)
|
338
|
+
}), t = yield fetch(`${P.apiUrl}/api/payments/create`, {
|
53
339
|
method: "POST",
|
54
|
-
headers:
|
55
|
-
body: JSON.stringify(
|
340
|
+
headers: J(),
|
341
|
+
body: JSON.stringify(r)
|
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:", t.status), !t.ok) {
|
344
|
+
const u = yield t.json();
|
345
|
+
throw console.error("Error creating payment:", u), new Error(u.error || `Failed to create payment: ${t.status}`);
|
346
|
+
}
|
347
|
+
const c = yield t.json();
|
348
|
+
return console.log("Create payment response data:", c), c;
|
349
|
+
} catch (r) {
|
350
|
+
throw console.error("Create payment error:", r), r;
|
65
351
|
}
|
66
|
-
}),
|
352
|
+
}), It = (s) => R(void 0, null, function* () {
|
67
353
|
try {
|
68
|
-
console.log("Getting payment:",
|
69
|
-
const
|
354
|
+
console.log("Getting payment:", s);
|
355
|
+
const r = yield fetch(`${P.apiUrl}/api/payments/${s}`, {
|
70
356
|
method: "GET",
|
71
|
-
headers:
|
357
|
+
headers: J()
|
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 (!r.ok) {
|
360
|
+
const c = yield r.json();
|
361
|
+
throw console.error("Error getting payment:", c), new Error(c.error || `Failed to get payment: ${r.status}`);
|
362
|
+
}
|
363
|
+
const t = yield r.json();
|
364
|
+
return console.log("Get payment response:", t), t;
|
365
|
+
} catch (r) {
|
366
|
+
throw console.error("Get payment error:", r), r;
|
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:", `${P.apiUrl}/api/payments/process`);
|
371
|
+
const r = yield fetch(`${P.apiUrl}/api/payments/process`, {
|
86
372
|
method: "POST",
|
87
|
-
headers:
|
88
|
-
body: JSON.stringify(
|
373
|
+
headers: J(),
|
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:", r.status), !r.ok) {
|
377
|
+
const c = yield r.json();
|
378
|
+
throw console.error("Error processing payment:", c), new Error(c.error || `Failed to process payment: ${r.status}`);
|
379
|
+
}
|
380
|
+
const t = yield r.json();
|
381
|
+
return console.log("Process payment response data:", t), t;
|
382
|
+
} catch (r) {
|
383
|
+
throw console.error("Process payment error:", r), r;
|
98
384
|
}
|
99
|
-
}),
|
100
|
-
if (!lr())
|
101
|
-
throw new Error("MetaMask is not installed");
|
385
|
+
}), Ft = () => R(void 0, null, function* () {
|
102
386
|
try {
|
103
|
-
|
104
|
-
|
105
|
-
|
387
|
+
const s = yield fetch(`${P.apiUrl}/api/networks`, {
|
388
|
+
method: "GET",
|
389
|
+
headers: J()
|
390
|
+
});
|
391
|
+
if (!s.ok) {
|
392
|
+
const t = yield s.json();
|
393
|
+
throw new Error(t.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
|
+
}), Bt = () => R(void 0, null, function* () {
|
400
|
+
try {
|
401
|
+
const s = yield fetch(`${P.apiUrl}/api/merchants/profile`, {
|
402
|
+
method: "GET",
|
403
|
+
headers: J()
|
404
|
+
});
|
405
|
+
if (!s.ok) {
|
406
|
+
const t = yield s.json();
|
407
|
+
throw new Error(t.error || `Failed to get merchant profile: ${s.status}`);
|
408
|
+
}
|
409
|
+
const r = yield s.json();
|
410
|
+
return r.merchant && r.merchant.walletAddresses && (P.merchantWalletAddresses = z(z({}, P.merchantWalletAddresses), r.merchant.walletAddresses)), r;
|
411
|
+
} catch (s) {
|
412
|
+
throw console.error("Get merchant profile error:", s), s;
|
413
|
+
}
|
414
|
+
}), Wt = (s, r) => R(void 0, null, function* () {
|
415
|
+
try {
|
416
|
+
const t = yield fetch(`${P.apiUrl}/api/wallets/validate`, {
|
417
|
+
method: "POST",
|
418
|
+
headers: J(),
|
419
|
+
body: JSON.stringify({ address: s, network: r })
|
420
|
+
});
|
421
|
+
if (!t.ok) {
|
422
|
+
const u = yield t.json();
|
423
|
+
throw new Error(u.error || `Failed to validate address: ${t.status}`);
|
424
|
+
}
|
425
|
+
return yield t.json();
|
426
|
+
} catch (t) {
|
427
|
+
throw console.error("Validate wallet address error:", t), t;
|
428
|
+
}
|
429
|
+
}), Qt = (s = "ethereum") => {
|
430
|
+
const t = {
|
431
|
+
ethereum: "0x",
|
432
|
+
bsc: "0x",
|
433
|
+
tron: "",
|
434
|
+
algorand: ""
|
435
|
+
}[s] || "0x", c = Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
436
|
+
return `${t}${c}`;
|
437
|
+
};
|
438
|
+
var be = { 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 = S, ft = Symbol.for("react.element"), gt = Symbol.for("react.fragment"), wt = Object.prototype.hasOwnProperty, pt = mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, yt = { key: !0, ref: !0, __self: !0, __source: !0 };
|
449
|
+
function Ae(s, r, t) {
|
450
|
+
var c, u = {}, h = null, y = null;
|
451
|
+
t !== void 0 && (h = "" + t), r.key !== void 0 && (h = "" + r.key), r.ref !== void 0 && (y = r.ref);
|
452
|
+
for (c in r)
|
453
|
+
wt.call(r, c) && !yt.hasOwnProperty(c) && (u[c] = r[c]);
|
454
|
+
if (s && s.defaultProps)
|
455
|
+
for (c in r = s.defaultProps, r)
|
456
|
+
u[c] === void 0 && (u[c] = r[c]);
|
457
|
+
return { $$typeof: ft, type: s, key: h, ref: y, props: u, _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 = gt;
|
460
|
+
ne.jsx = Ae;
|
461
|
+
ne.jsxs = Ae;
|
462
|
+
be.exports = ne;
|
463
|
+
var a = be.exports;
|
464
|
+
const ve = ye(), xt = () => xe(ve), zt = ({ initialTheme: s = "light", children: r }) => {
|
465
|
+
const [t, c] = U(s), u = () => {
|
466
|
+
c((h) => h === "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(t);
|
470
|
+
}, [t]), /* @__PURE__ */ a.jsx(ve.Provider, { value: { theme: t, setTheme: c, toggleTheme: u }, children: r });
|
471
|
+
}, Te = ye(), Nt = () => xe(Te), Gt = ({
|
472
|
+
apiKey: s,
|
473
|
+
apiSecret: r,
|
474
|
+
apiUrl: t = "http://localhost:9000",
|
475
|
+
merchantWalletAddress: c = null,
|
762
476
|
// New prop for merchant wallet address
|
763
|
-
merchantSolWalletAddress:
|
477
|
+
merchantSolWalletAddress: u = null,
|
764
478
|
// New prop for Solana wallet address
|
765
|
-
debug:
|
766
|
-
children:
|
479
|
+
debug: h = !1,
|
480
|
+
children: y
|
767
481
|
}) => {
|
768
|
-
const [
|
769
|
-
|
770
|
-
if (!
|
771
|
-
|
482
|
+
const [w, e] = U(!1), [n, o] = U(null), [i, l] = U(null);
|
483
|
+
Z(() => {
|
484
|
+
if (!s || !r) {
|
485
|
+
o("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: r,
|
492
|
+
apiUrl: t,
|
493
|
+
merchantWalletAddress: c,
|
780
494
|
// Pass wallet address to API service
|
781
|
-
merchantSolWalletAddress:
|
782
|
-
}),
|
783
|
-
apiKey:
|
784
|
-
apiUrl:
|
785
|
-
merchantWalletAddress:
|
786
|
-
merchantSolWalletAddress:
|
495
|
+
merchantSolWalletAddress: u
|
496
|
+
}), e(!0), h && console.log("Coinley SDK initialized with:", {
|
497
|
+
apiKey: s,
|
498
|
+
apiUrl: t,
|
499
|
+
merchantWalletAddress: c ? `${c.substring(0, 6)}...${c.substring(c.length - 4)}` : "Not provided",
|
500
|
+
merchantSolWalletAddress: u ? `${u.substring(0, 6)}...${u.substring(u.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:
|
801
|
-
paymentData:
|
802
|
-
storePaymentData: (
|
502
|
+
} catch (m) {
|
503
|
+
o(m.message), h && console.error("Coinley SDK initialization error:", m);
|
504
|
+
}
|
505
|
+
}, [s, r, t, c, u, h]);
|
506
|
+
const d = {
|
507
|
+
apiKey: s,
|
508
|
+
apiSecret: r,
|
509
|
+
apiUrl: t,
|
510
|
+
merchantWalletAddress: c,
|
511
|
+
merchantSolWalletAddress: u,
|
512
|
+
isInitialized: w,
|
513
|
+
error: n,
|
514
|
+
debug: h,
|
515
|
+
paymentData: i,
|
516
|
+
storePaymentData: (m) => (l(m), m)
|
803
517
|
};
|
804
|
-
return /* @__PURE__ */
|
518
|
+
return /* @__PURE__ */ a.jsx(Te.Provider, { value: d, 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 Et = Object.defineProperty, se = Object.getOwnPropertySymbols, Ce = Object.prototype.hasOwnProperty, je = Object.prototype.propertyIsEnumerable, pe = (s, r, t) => r in s ? Et(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t, ie = (s, r) => {
|
521
|
+
for (var t in r || (r = {}))
|
522
|
+
Ce.call(r, t) && pe(s, t, r[t]);
|
523
|
+
if (se)
|
524
|
+
for (var t of se(r))
|
525
|
+
je.call(r, t) && pe(s, t, r[t]);
|
526
|
+
return s;
|
527
|
+
}, ce = (s, r) => {
|
528
|
+
var t = {};
|
529
|
+
for (var c in s)
|
530
|
+
Ce.call(s, c) && r.indexOf(c) < 0 && (t[c] = s[c]);
|
531
|
+
if (s != null && se)
|
532
|
+
for (var c of se(s))
|
533
|
+
r.indexOf(c) < 0 && je.call(s, c) && (t[c] = s[c]);
|
534
|
+
return t;
|
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 r = 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(e, n, o, i) {
|
550
|
+
if (this.version = e, this.errorCorrectionLevel = n, this.modules = [], this.isFunction = [], e < E.MIN_VERSION || e > E.MAX_VERSION)
|
837
551
|
throw new RangeError("Version value out of range");
|
838
|
-
if (
|
552
|
+
if (i < -1 || i > 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 = e * 4 + 17;
|
555
|
+
let l = [];
|
556
|
+
for (let d = 0; d < this.size; d++)
|
557
|
+
l.push(!1);
|
558
|
+
for (let d = 0; d < this.size; d++)
|
559
|
+
this.modules.push(l.slice()), this.isFunction.push(l.slice());
|
846
560
|
this.drawFunctionPatterns();
|
847
|
-
const
|
848
|
-
if (this.drawCodewords(
|
849
|
-
let
|
850
|
-
for (let
|
851
|
-
this.applyMask(
|
852
|
-
const
|
853
|
-
|
561
|
+
const f = this.addEccAndInterleave(o);
|
562
|
+
if (this.drawCodewords(f), i == -1) {
|
563
|
+
let d = 1e9;
|
564
|
+
for (let m = 0; m < 8; m++) {
|
565
|
+
this.applyMask(m), this.drawFormatBits(m);
|
566
|
+
const g = this.getPenaltyScore();
|
567
|
+
g < d && (i = m, d = g), this.applyMask(m);
|
854
568
|
}
|
855
569
|
}
|
856
|
-
|
570
|
+
u(0 <= i && i <= 7), this.mask = i, this.applyMask(i), this.drawFormatBits(i), 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(e, n) {
|
579
|
+
const o = s.QrSegment.makeSegments(e);
|
580
|
+
return E.encodeSegments(o, 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(e, n) {
|
587
|
+
const o = s.QrSegment.makeBytes(e);
|
588
|
+
return E.encodeSegments([o], 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(e, n, o = 1, i = 40, l = -1, f = !0) {
|
601
|
+
if (!(E.MIN_VERSION <= o && o <= i && i <= E.MAX_VERSION) || l < -1 || l > 7)
|
888
602
|
throw new RangeError("Invalid value");
|
889
|
-
let
|
890
|
-
for (
|
891
|
-
const
|
892
|
-
if (
|
893
|
-
|
603
|
+
let d, m;
|
604
|
+
for (d = o; ; d++) {
|
605
|
+
const p = E.getNumDataCodewords(d, n) * 8, j = y.getTotalBits(e, d);
|
606
|
+
if (j <= p) {
|
607
|
+
m = j;
|
894
608
|
break;
|
895
609
|
}
|
896
|
-
if (
|
610
|
+
if (d >= i)
|
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
|
+
f && m <= E.getNumDataCodewords(d, p) * 8 && (n = p);
|
615
|
+
let g = [];
|
616
|
+
for (const p of e) {
|
617
|
+
t(p.mode.modeBits, 4, g), t(p.numChars, p.mode.numCharCountBits(d), g);
|
618
|
+
for (const j of p.getData())
|
619
|
+
g.push(j);
|
906
620
|
}
|
907
|
-
|
908
|
-
const
|
909
|
-
|
910
|
-
for (let
|
911
|
-
|
912
|
-
let
|
913
|
-
for (;
|
914
|
-
|
915
|
-
return
|
621
|
+
u(g.length == m);
|
622
|
+
const b = E.getNumDataCodewords(d, n) * 8;
|
623
|
+
u(g.length <= b), t(0, Math.min(4, b - g.length), g), t(0, (8 - g.length % 8) % 8, g), u(g.length % 8 == 0);
|
624
|
+
for (let p = 236; g.length < b; p ^= 253)
|
625
|
+
t(p, 8, g);
|
626
|
+
let v = [];
|
627
|
+
for (; v.length * 8 < g.length; )
|
628
|
+
v.push(0);
|
629
|
+
return g.forEach((p, j) => v[j >>> 3] |= p << 7 - (j & 7)), new E(d, n, v, l);
|
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(e, n) {
|
636
|
+
return 0 <= e && e < this.size && 0 <= n && n < this.size && this.modules[n][e];
|
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 o = 0; o < this.size; o++)
|
646
|
+
this.setFunctionModule(6, o, o % 2 == 0), this.setFunctionModule(o, 6, o % 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
|
937
|
-
|
648
|
+
const e = this.getAlignmentPatternPositions(), n = e.length;
|
649
|
+
for (let o = 0; o < n; o++)
|
650
|
+
for (let i = 0; i < n; i++)
|
651
|
+
o == 0 && i == 0 || o == 0 && i == n - 1 || o == n - 1 && i == 0 || this.drawAlignmentPattern(e[o], e[i]);
|
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
|
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(e) {
|
657
|
+
const n = this.errorCorrectionLevel.formatBits << 3 | e;
|
658
|
+
let o = n;
|
659
|
+
for (let l = 0; l < 10; l++)
|
660
|
+
o = o << 1 ^ (o >>> 9) * 1335;
|
661
|
+
const i = (n << 10 | o) ^ 21522;
|
662
|
+
u(i >>> 15 == 0);
|
663
|
+
for (let l = 0; l <= 5; l++)
|
664
|
+
this.setFunctionModule(8, l, c(i, l));
|
665
|
+
this.setFunctionModule(8, 7, c(i, 6)), this.setFunctionModule(8, 8, c(i, 7)), this.setFunctionModule(7, 8, c(i, 8));
|
666
|
+
for (let l = 9; l < 15; l++)
|
667
|
+
this.setFunctionModule(14 - l, 8, c(i, l));
|
668
|
+
for (let l = 0; l < 8; l++)
|
669
|
+
this.setFunctionModule(this.size - 1 - l, 8, c(i, l));
|
670
|
+
for (let l = 8; l < 15; l++)
|
671
|
+
this.setFunctionModule(8, this.size - 15 + l, c(i, l));
|
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
|
972
|
-
this.setFunctionModule(
|
679
|
+
let e = this.version;
|
680
|
+
for (let o = 0; o < 12; o++)
|
681
|
+
e = e << 1 ^ (e >>> 11) * 7973;
|
682
|
+
const n = this.version << 12 | e;
|
683
|
+
u(n >>> 18 == 0);
|
684
|
+
for (let o = 0; o < 18; o++) {
|
685
|
+
const i = c(n, o), l = this.size - 11 + o % 3, f = Math.floor(o / 3);
|
686
|
+
this.setFunctionModule(l, f, i), this.setFunctionModule(f, l, i);
|
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
|
979
|
-
for (let
|
980
|
-
const
|
981
|
-
0 <=
|
691
|
+
drawFinderPattern(e, n) {
|
692
|
+
for (let o = -4; o <= 4; o++)
|
693
|
+
for (let i = -4; i <= 4; i++) {
|
694
|
+
const l = Math.max(Math.abs(i), Math.abs(o)), f = e + i, d = n + o;
|
695
|
+
0 <= f && f < this.size && 0 <= d && d < this.size && this.setFunctionModule(f, d, l != 2 && l != 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
|
988
|
-
for (let
|
989
|
-
this.setFunctionModule(
|
700
|
+
drawAlignmentPattern(e, n) {
|
701
|
+
for (let o = -2; o <= 2; o++)
|
702
|
+
for (let i = -2; i <= 2; i++)
|
703
|
+
this.setFunctionModule(e + i, n + o, Math.max(Math.abs(i), Math.abs(o)) != 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(e, n, o) {
|
708
|
+
this.modules[n][e] = o, this.isFunction[n][e] = !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(e) {
|
714
|
+
const n = this.version, o = this.errorCorrectionLevel;
|
715
|
+
if (e.length != E.getNumDataCodewords(n, o))
|
1002
716
|
throw new RangeError("Invalid argument");
|
1003
|
-
const
|
1004
|
-
let
|
1005
|
-
const
|
1006
|
-
for (let
|
1007
|
-
let
|
1008
|
-
|
1009
|
-
const
|
1010
|
-
|
717
|
+
const i = E.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][n], l = E.ECC_CODEWORDS_PER_BLOCK[o.ordinal][n], f = Math.floor(E.getNumRawDataModules(n) / 8), d = i - f % i, m = Math.floor(f / i);
|
718
|
+
let g = [];
|
719
|
+
const b = E.reedSolomonComputeDivisor(l);
|
720
|
+
for (let p = 0, j = 0; p < i; p++) {
|
721
|
+
let M = e.slice(j, j + m - l + (p < d ? 0 : 1));
|
722
|
+
j += M.length;
|
723
|
+
const F = E.reedSolomonComputeRemainder(M, b);
|
724
|
+
p < d && M.push(0), g.push(M.concat(F));
|
1011
725
|
}
|
1012
|
-
let
|
1013
|
-
for (let
|
1014
|
-
|
1015
|
-
(
|
726
|
+
let v = [];
|
727
|
+
for (let p = 0; p < g[0].length; p++)
|
728
|
+
g.forEach((j, M) => {
|
729
|
+
(p != m - l || M >= d) && v.push(j[p]);
|
1016
730
|
});
|
1017
|
-
return
|
731
|
+
return u(v.length == f), v;
|
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(e) {
|
736
|
+
if (e.length != Math.floor(E.getNumRawDataModules(this.version) / 8))
|
1023
737
|
throw new RangeError("Invalid argument");
|
1024
|
-
let
|
1025
|
-
for (let
|
1026
|
-
|
1027
|
-
for (let
|
1028
|
-
for (let
|
1029
|
-
const
|
1030
|
-
!this.isFunction[
|
738
|
+
let n = 0;
|
739
|
+
for (let o = this.size - 1; o >= 1; o -= 2) {
|
740
|
+
o == 6 && (o = 5);
|
741
|
+
for (let i = 0; i < this.size; i++)
|
742
|
+
for (let l = 0; l < 2; l++) {
|
743
|
+
const f = o - l, m = (o + 1 & 2) == 0 ? this.size - 1 - i : i;
|
744
|
+
!this.isFunction[m][f] && n < e.length * 8 && (this.modules[m][f] = c(e[n >>> 3], 7 - (n & 7)), n++);
|
1031
745
|
}
|
1032
746
|
}
|
1033
|
-
|
747
|
+
u(n == e.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(e) {
|
755
|
+
if (e < 0 || e > 7)
|
1042
756
|
throw new RangeError("Mask value out of range");
|
1043
|
-
for (let
|
1044
|
-
for (let
|
1045
|
-
let
|
1046
|
-
switch (
|
757
|
+
for (let n = 0; n < this.size; n++)
|
758
|
+
for (let o = 0; o < this.size; o++) {
|
759
|
+
let i;
|
760
|
+
switch (e) {
|
1047
761
|
case 0:
|
1048
|
-
|
762
|
+
i = (o + n) % 2 == 0;
|
1049
763
|
break;
|
1050
764
|
case 1:
|
1051
|
-
|
765
|
+
i = n % 2 == 0;
|
1052
766
|
break;
|
1053
767
|
case 2:
|
1054
|
-
|
768
|
+
i = o % 3 == 0;
|
1055
769
|
break;
|
1056
770
|
case 3:
|
1057
|
-
|
771
|
+
i = (o + n) % 3 == 0;
|
1058
772
|
break;
|
1059
773
|
case 4:
|
1060
|
-
|
774
|
+
i = (Math.floor(o / 3) + Math.floor(n / 2)) % 2 == 0;
|
1061
775
|
break;
|
1062
776
|
case 5:
|
1063
|
-
|
777
|
+
i = o * n % 2 + o * n % 3 == 0;
|
1064
778
|
break;
|
1065
779
|
case 6:
|
1066
|
-
|
780
|
+
i = (o * n % 2 + o * n % 3) % 2 == 0;
|
1067
781
|
break;
|
1068
782
|
case 7:
|
1069
|
-
|
783
|
+
i = ((o + n) % 2 + o * 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][o] && i && (this.modules[n][o] = !this.modules[n][o]);
|
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 e = 0;
|
795
|
+
for (let l = 0; l < this.size; l++) {
|
796
|
+
let f = !1, d = 0, m = [0, 0, 0, 0, 0, 0, 0];
|
797
|
+
for (let g = 0; g < this.size; g++)
|
798
|
+
this.modules[l][g] == f ? (d++, d == 5 ? e += E.PENALTY_N1 : d > 5 && e++) : (this.finderPenaltyAddHistory(d, m), f || (e += this.finderPenaltyCountPatterns(m) * E.PENALTY_N3), f = this.modules[l][g], d = 1);
|
799
|
+
e += this.finderPenaltyTerminateAndCount(f, d, m) * E.PENALTY_N3;
|
1086
800
|
}
|
1087
|
-
for (let
|
1088
|
-
let
|
1089
|
-
for (let
|
1090
|
-
this.modules[
|
1091
|
-
|
801
|
+
for (let l = 0; l < this.size; l++) {
|
802
|
+
let f = !1, d = 0, m = [0, 0, 0, 0, 0, 0, 0];
|
803
|
+
for (let g = 0; g < this.size; g++)
|
804
|
+
this.modules[g][l] == f ? (d++, d == 5 ? e += E.PENALTY_N1 : d > 5 && e++) : (this.finderPenaltyAddHistory(d, m), f || (e += this.finderPenaltyCountPatterns(m) * E.PENALTY_N3), f = this.modules[g][l], d = 1);
|
805
|
+
e += this.finderPenaltyTerminateAndCount(f, d, m) * E.PENALTY_N3;
|
1092
806
|
}
|
1093
|
-
for (let
|
1094
|
-
for (let
|
1095
|
-
const
|
1096
|
-
|
807
|
+
for (let l = 0; l < this.size - 1; l++)
|
808
|
+
for (let f = 0; f < this.size - 1; f++) {
|
809
|
+
const d = this.modules[l][f];
|
810
|
+
d == this.modules[l][f + 1] && d == this.modules[l + 1][f] && d == this.modules[l + 1][f + 1] && (e += E.PENALTY_N2);
|
1097
811
|
}
|
1098
|
-
let
|
1099
|
-
for (const
|
1100
|
-
|
1101
|
-
const
|
1102
|
-
return
|
812
|
+
let n = 0;
|
813
|
+
for (const l of this.modules)
|
814
|
+
n = l.reduce((f, d) => f + (d ? 1 : 0), n);
|
815
|
+
const o = this.size * this.size, i = Math.ceil(Math.abs(n * 20 - o * 10) / o) - 1;
|
816
|
+
return u(0 <= i && i <= 9), e += i * E.PENALTY_N4, u(0 <= e && e <= 2568888), e;
|
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
|
1115
|
-
|
1116
|
-
return
|
826
|
+
const e = Math.floor(this.version / 7) + 2, n = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2;
|
827
|
+
let o = [6];
|
828
|
+
for (let i = this.size - 7; o.length < e; i -= n)
|
829
|
+
o.splice(1, 0, i);
|
830
|
+
return o;
|
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(e) {
|
837
|
+
if (e < E.MIN_VERSION || e > E.MAX_VERSION)
|
1124
838
|
throw new RangeError("Version number out of range");
|
1125
|
-
let
|
1126
|
-
if (
|
1127
|
-
const
|
1128
|
-
|
839
|
+
let n = (16 * e + 128) * e + 64;
|
840
|
+
if (e >= 2) {
|
841
|
+
const o = Math.floor(e / 7) + 2;
|
842
|
+
n -= (25 * o - 10) * o - 55, e >= 7 && (n -= 36);
|
1129
843
|
}
|
1130
|
-
return
|
844
|
+
return u(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(e, n) {
|
850
|
+
return Math.floor(E.getNumRawDataModules(e) / 8) - E.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e] * E.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e];
|
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(e) {
|
855
|
+
if (e < 1 || e > 255)
|
1142
856
|
throw new RangeError("Degree out of range");
|
1143
|
-
let
|
1144
|
-
for (let
|
1145
|
-
|
1146
|
-
|
1147
|
-
let
|
1148
|
-
for (let
|
1149
|
-
for (let
|
1150
|
-
|
1151
|
-
|
857
|
+
let n = [];
|
858
|
+
for (let i = 0; i < e - 1; i++)
|
859
|
+
n.push(0);
|
860
|
+
n.push(1);
|
861
|
+
let o = 1;
|
862
|
+
for (let i = 0; i < e; i++) {
|
863
|
+
for (let l = 0; l < n.length; l++)
|
864
|
+
n[l] = E.reedSolomonMultiply(n[l], o), l + 1 < n.length && (n[l] ^= n[l + 1]);
|
865
|
+
o = E.reedSolomonMultiply(o, 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
|
1159
|
-
const
|
1160
|
-
|
870
|
+
static reedSolomonComputeRemainder(e, n) {
|
871
|
+
let o = n.map((i) => 0);
|
872
|
+
for (const i of e) {
|
873
|
+
const l = i ^ o.shift();
|
874
|
+
o.push(0), n.forEach((f, d) => o[d] ^= E.reedSolomonMultiply(f, l));
|
1161
875
|
}
|
1162
|
-
return
|
876
|
+
return o;
|
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(e, n) {
|
881
|
+
if (e >>> 8 || n >>> 8)
|
1168
882
|
throw new RangeError("Byte out of range");
|
1169
|
-
let
|
1170
|
-
for (let
|
1171
|
-
|
1172
|
-
return
|
883
|
+
let o = 0;
|
884
|
+
for (let i = 7; i >= 0; i--)
|
885
|
+
o = o << 1 ^ (o >>> 7) * 285, o ^= (n >>> i & 1) * e;
|
886
|
+
return u(o >>> 8 == 0), o;
|
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(e) {
|
891
|
+
const n = e[1];
|
892
|
+
u(n <= this.size * 3);
|
893
|
+
const o = n > 0 && e[2] == n && e[3] == n * 3 && e[4] == n && e[5] == n;
|
894
|
+
return (o && e[0] >= n * 4 && e[6] >= n ? 1 : 0) + (o && e[6] >= n * 4 && e[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(e, n, o) {
|
898
|
+
return e && (this.finderPenaltyAddHistory(n, o), n = 0), n += this.size, this.finderPenaltyAddHistory(n, o), this.finderPenaltyCountPatterns(o);
|
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(e, n) {
|
902
|
+
n[0] == 0 && (e += this.size), n.pop(), n.unshift(e);
|
1189
903
|
}
|
1190
904
|
};
|
1191
|
-
|
905
|
+
r.MIN_VERSION = 1, r.MAX_VERSION = 40, r.PENALTY_N1 = 3, r.PENALTY_N2 = 3, r.PENALTY_N3 = 40, r.PENALTY_N4 = 10, r.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
|
+
], r.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 = r;
|
928
|
+
function t(w, e, n) {
|
929
|
+
if (e < 0 || e > 31 || w >>> e)
|
1216
930
|
throw new RangeError("Value out of range");
|
1217
|
-
for (let
|
1218
|
-
|
931
|
+
for (let o = e - 1; o >= 0; o--)
|
932
|
+
n.push(w >>> o & 1);
|
1219
933
|
}
|
1220
|
-
function
|
1221
|
-
return (
|
934
|
+
function c(w, e) {
|
935
|
+
return (w >>> e & 1) != 0;
|
1222
936
|
}
|
1223
|
-
function
|
1224
|
-
if (!
|
937
|
+
function u(w) {
|
938
|
+
if (!w)
|
1225
939
|
throw new Error("Assertion error");
|
1226
940
|
}
|
1227
|
-
const
|
941
|
+
const h = class k {
|
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(e, n, o) {
|
947
|
+
if (this.mode = e, this.numChars = n, this.bitData = o, n < 0)
|
1234
948
|
throw new RangeError("Invalid argument");
|
1235
|
-
this.bitData =
|
949
|
+
this.bitData = o.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(e) {
|
956
|
+
let n = [];
|
957
|
+
for (const o of e)
|
958
|
+
t(o, 8, n);
|
959
|
+
return new k(k.Mode.BYTE, e.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(e) {
|
963
|
+
if (!k.isNumeric(e))
|
1250
964
|
throw new RangeError("String contains non-numeric characters");
|
1251
|
-
let
|
1252
|
-
for (let
|
1253
|
-
const
|
1254
|
-
|
965
|
+
let n = [];
|
966
|
+
for (let o = 0; o < e.length; ) {
|
967
|
+
const i = Math.min(e.length - o, 3);
|
968
|
+
t(parseInt(e.substring(o, o + i), 10), i * 3 + 1, n), o += i;
|
1255
969
|
}
|
1256
|
-
return new
|
970
|
+
return new k(k.Mode.NUMERIC, e.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(e) {
|
976
|
+
if (!k.isAlphanumeric(e))
|
1263
977
|
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
1264
|
-
let
|
1265
|
-
for (
|
1266
|
-
let
|
1267
|
-
|
978
|
+
let n = [], o;
|
979
|
+
for (o = 0; o + 2 <= e.length; o += 2) {
|
980
|
+
let i = k.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)) * 45;
|
981
|
+
i += k.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o + 1)), t(i, 11, n);
|
1268
982
|
}
|
1269
|
-
return
|
983
|
+
return o < e.length && t(k.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)), 6, n), new k(k.Mode.ALPHANUMERIC, e.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(e) {
|
988
|
+
return e == "" ? [] : k.isNumeric(e) ? [k.makeNumeric(e)] : k.isAlphanumeric(e) ? [k.makeAlphanumeric(e)] : [k.makeBytes(k.toUtf8ByteArray(e))];
|
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(e) {
|
993
|
+
let n = [];
|
994
|
+
if (e < 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 (e < 128)
|
997
|
+
t(e, 8, n);
|
998
|
+
else if (e < 16384)
|
999
|
+
t(2, 2, n), t(e, 14, n);
|
1000
|
+
else if (e < 1e6)
|
1001
|
+
t(6, 3, n), t(e, 21, n);
|
1288
1002
|
else
|
1289
1003
|
throw new RangeError("ECI assignment value out of range");
|
1290
|
-
return new
|
1004
|
+
return new k(k.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(e) {
|
1009
|
+
return k.NUMERIC_REGEX.test(e);
|
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(e) {
|
1015
|
+
return k.ALPHANUMERIC_REGEX.test(e);
|
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
|
1313
|
-
const
|
1314
|
-
if (
|
1024
|
+
static getTotalBits(e, n) {
|
1025
|
+
let o = 0;
|
1026
|
+
for (const i of e) {
|
1027
|
+
const l = i.mode.numCharCountBits(n);
|
1028
|
+
if (i.numChars >= 1 << l)
|
1315
1029
|
return 1 / 0;
|
1316
|
-
|
1030
|
+
o += 4 + l + i.bitData.length;
|
1317
1031
|
}
|
1318
|
-
return
|
1032
|
+
return o;
|
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(e) {
|
1036
|
+
e = encodeURI(e);
|
1037
|
+
let n = [];
|
1038
|
+
for (let o = 0; o < e.length; o++)
|
1039
|
+
e.charAt(o) != "%" ? n.push(e.charCodeAt(o)) : (n.push(parseInt(e.substring(o + 1, o + 3), 16)), o += 2);
|
1040
|
+
return n;
|
1327
1041
|
}
|
1328
1042
|
};
|
1329
|
-
|
1330
|
-
let
|
1331
|
-
|
1332
|
-
})(
|
1333
|
-
((
|
1334
|
-
((
|
1335
|
-
const
|
1043
|
+
h.NUMERIC_REGEX = /^[0-9]*$/, h.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, h.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
1044
|
+
let y = h;
|
1045
|
+
s.QrSegment = h;
|
1046
|
+
})(K || (K = {}));
|
1047
|
+
((s) => {
|
1048
|
+
((r) => {
|
1049
|
+
const t = class {
|
1336
1050
|
// The QR Code can tolerate about 30% erroneous codewords
|
1337
1051
|
/*-- Constructor and fields --*/
|
1338
|
-
constructor(
|
1339
|
-
this.ordinal =
|
1052
|
+
constructor(u, h) {
|
1053
|
+
this.ordinal = u, this.formatBits = h;
|
1340
1054
|
}
|
1341
1055
|
};
|
1342
|
-
|
1343
|
-
})(
|
1344
|
-
})(
|
1345
|
-
((
|
1346
|
-
((
|
1347
|
-
const
|
1056
|
+
t.LOW = new t(0, 1), t.MEDIUM = new t(1, 0), t.QUARTILE = new t(2, 3), t.HIGH = new t(3, 2), r.Ecc = t;
|
1057
|
+
})(s.QrCode || (s.QrCode = {}));
|
1058
|
+
})(K || (K = {}));
|
1059
|
+
((s) => {
|
1060
|
+
((r) => {
|
1061
|
+
const t = class {
|
1348
1062
|
/*-- Constructor and fields --*/
|
1349
|
-
constructor(
|
1350
|
-
this.modeBits =
|
1063
|
+
constructor(u, h) {
|
1064
|
+
this.modeBits = u, this.numBitsCharCount = h;
|
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(u) {
|
1070
|
+
return this.numBitsCharCount[Math.floor((u + 7) / 17)];
|
1357
1071
|
}
|
1358
1072
|
};
|
1359
|
-
|
1360
|
-
})(
|
1361
|
-
})(
|
1362
|
-
var
|
1073
|
+
t.NUMERIC = new t(1, [10, 12, 14]), t.ALPHANUMERIC = new t(2, [9, 11, 13]), t.BYTE = new t(4, [8, 16, 16]), t.KANJI = new t(8, [8, 10, 12]), t.ECI = new t(7, [0, 0, 0]), r.Mode = t;
|
1074
|
+
})(s.QrSegment || (s.QrSegment = {}));
|
1075
|
+
})(K || (K = {}));
|
1076
|
+
var Y = 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 bt = {
|
1083
|
+
L: Y.QrCode.Ecc.LOW,
|
1084
|
+
M: Y.QrCode.Ecc.MEDIUM,
|
1085
|
+
Q: Y.QrCode.Ecc.QUARTILE,
|
1086
|
+
H: Y.QrCode.Ecc.HIGH
|
1087
|
+
}, Me = 128, ke = "L", Re = "#FFFFFF", Se = "#000000", Le = !1, Pe = 1, At = 4, vt = 0, Tt = 0.1;
|
1088
|
+
function Oe(s, r = 0) {
|
1089
|
+
const t = [];
|
1090
|
+
return s.forEach(function(c, u) {
|
1091
|
+
let h = null;
|
1092
|
+
c.forEach(function(y, w) {
|
1093
|
+
if (!y && h !== null) {
|
1094
|
+
t.push(
|
1095
|
+
`M${h + r} ${u + r}h${w - h}v1H${h + r}z`
|
1096
|
+
), h = null;
|
1383
1097
|
return;
|
1384
1098
|
}
|
1385
|
-
if (
|
1386
|
-
if (!
|
1099
|
+
if (w === c.length - 1) {
|
1100
|
+
if (!y)
|
1387
1101
|
return;
|
1388
|
-
|
1389
|
-
`M${
|
1102
|
+
h === null ? t.push(`M${w + r},${u + r} h1v1H${w + r}z`) : t.push(
|
1103
|
+
`M${h + r},${u + r} h${w + 1 - h}v1H${h + r}z`
|
1390
1104
|
);
|
1391
1105
|
return;
|
1392
1106
|
}
|
1393
|
-
|
1107
|
+
y && h === null && (h = w);
|
1394
1108
|
});
|
1395
|
-
}),
|
1109
|
+
}), t.join("");
|
1396
1110
|
}
|
1397
|
-
function
|
1398
|
-
return
|
1111
|
+
function De(s, r) {
|
1112
|
+
return s.slice().map((t, c) => c < r.y || c >= r.y + r.h ? t : t.map((u, h) => h < r.x || h >= r.x + r.w ? u : !1));
|
1399
1113
|
}
|
1400
|
-
function
|
1401
|
-
if (
|
1114
|
+
function Ct(s, r, t, c) {
|
1115
|
+
if (c == null)
|
1402
1116
|
return null;
|
1403
|
-
const
|
1404
|
-
let
|
1405
|
-
if (
|
1406
|
-
let
|
1407
|
-
|
1117
|
+
const u = s.length + t * 2, h = Math.floor(r * Tt), y = u / r, w = (c.width || h) * y, e = (c.height || h) * y, n = c.x == null ? s.length / 2 - w / 2 : c.x * y, o = c.y == null ? s.length / 2 - e / 2 : c.y * y, i = c.opacity == null ? 1 : c.opacity;
|
1118
|
+
let l = null;
|
1119
|
+
if (c.excavate) {
|
1120
|
+
let d = Math.floor(n), m = Math.floor(o), g = Math.ceil(w + n - d), b = Math.ceil(e + o - m);
|
1121
|
+
l = { x: d, y: m, w: g, h: b };
|
1408
1122
|
}
|
1409
|
-
const
|
1410
|
-
return { x:
|
1123
|
+
const f = c.crossOrigin;
|
1124
|
+
return { x: n, y: o, h: e, w, excavation: l, opacity: i, crossOrigin: f };
|
1411
1125
|
}
|
1412
|
-
function
|
1413
|
-
return
|
1126
|
+
function jt(s, r) {
|
1127
|
+
return r != null ? Math.max(Math.floor(r), 0) : s ? At : vt;
|
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: r,
|
1132
|
+
minVersion: t,
|
1133
|
+
includeMargin: c,
|
1134
|
+
marginSize: u,
|
1135
|
+
imageSettings: h,
|
1136
|
+
size: y,
|
1137
|
+
boostLevel: w
|
1424
1138
|
}) {
|
1425
|
-
let
|
1426
|
-
const
|
1427
|
-
return
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1139
|
+
let e = S.useMemo(() => {
|
1140
|
+
const d = (Array.isArray(s) ? s : [s]).reduce((m, g) => (m.push(...Y.QrSegment.makeSegments(g)), m), []);
|
1141
|
+
return Y.QrCode.encodeSegments(
|
1142
|
+
d,
|
1143
|
+
bt[r],
|
1144
|
+
t,
|
1431
1145
|
void 0,
|
1432
1146
|
void 0,
|
1433
|
-
|
1147
|
+
w
|
1434
1148
|
);
|
1435
|
-
}, [
|
1436
|
-
const { cells:
|
1437
|
-
let
|
1438
|
-
const
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1149
|
+
}, [s, r, t, w]);
|
1150
|
+
const { cells: n, margin: o, numCells: i, calculatedImageSettings: l } = S.useMemo(() => {
|
1151
|
+
let f = e.getModules();
|
1152
|
+
const d = jt(c, u), m = f.length + d * 2, g = Ct(
|
1153
|
+
f,
|
1154
|
+
y,
|
1155
|
+
d,
|
1156
|
+
h
|
1443
1157
|
);
|
1444
1158
|
return {
|
1445
|
-
cells:
|
1446
|
-
margin:
|
1447
|
-
numCells:
|
1448
|
-
calculatedImageSettings:
|
1159
|
+
cells: f,
|
1160
|
+
margin: d,
|
1161
|
+
numCells: m,
|
1162
|
+
calculatedImageSettings: g
|
1449
1163
|
};
|
1450
|
-
}, [
|
1164
|
+
}, [e, y, h, c, u]);
|
1451
1165
|
return {
|
1452
|
-
qrcode:
|
1453
|
-
margin:
|
1454
|
-
cells:
|
1455
|
-
numCells:
|
1456
|
-
calculatedImageSettings:
|
1166
|
+
qrcode: e,
|
1167
|
+
margin: o,
|
1168
|
+
cells: n,
|
1169
|
+
numCells: i,
|
1170
|
+
calculatedImageSettings: l
|
1457
1171
|
};
|
1458
1172
|
}
|
1459
|
-
var
|
1173
|
+
var Mt = 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:
|
1476
|
-
boostLevel:
|
1477
|
-
marginSize:
|
1478
|
-
imageSettings:
|
1479
|
-
} =
|
1180
|
+
}(), kt = S.forwardRef(
|
1181
|
+
function(r, t) {
|
1182
|
+
const c = r, {
|
1183
|
+
value: u,
|
1184
|
+
size: h = Me,
|
1185
|
+
level: y = ke,
|
1186
|
+
bgColor: w = Re,
|
1187
|
+
fgColor: e = Se,
|
1188
|
+
includeMargin: n = Le,
|
1189
|
+
minVersion: o = Pe,
|
1190
|
+
boostLevel: i,
|
1191
|
+
marginSize: l,
|
1192
|
+
imageSettings: f
|
1193
|
+
} = c, m = ce(c, [
|
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: g } = m, b = ce(m, ["style"]), v = f == null ? void 0 : f.src, p = S.useRef(null), j = S.useRef(null), M = S.useCallback(
|
1205
|
+
(W) => {
|
1206
|
+
p.current = W, typeof t == "function" ? t(W) : t && (t.current = W);
|
1493
1207
|
},
|
1494
|
-
[
|
1495
|
-
), [
|
1496
|
-
value:
|
1497
|
-
level:
|
1498
|
-
minVersion:
|
1499
|
-
boostLevel:
|
1500
|
-
includeMargin:
|
1501
|
-
marginSize:
|
1502
|
-
imageSettings:
|
1503
|
-
size:
|
1208
|
+
[t]
|
1209
|
+
), [F, V] = S.useState(!1), { margin: x, cells: T, numCells: q, calculatedImageSettings: I } = Ue({
|
1210
|
+
value: u,
|
1211
|
+
level: y,
|
1212
|
+
minVersion: o,
|
1213
|
+
boostLevel: i,
|
1214
|
+
includeMargin: n,
|
1215
|
+
marginSize: l,
|
1216
|
+
imageSettings: f,
|
1217
|
+
size: h
|
1504
1218
|
});
|
1505
|
-
|
1506
|
-
if (
|
1507
|
-
const
|
1508
|
-
if (!
|
1219
|
+
S.useEffect(() => {
|
1220
|
+
if (p.current != null) {
|
1221
|
+
const W = p.current, O = W.getContext("2d");
|
1222
|
+
if (!O)
|
1509
1223
|
return;
|
1510
|
-
let
|
1511
|
-
const
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1224
|
+
let $ = T;
|
1225
|
+
const H = j.current, te = I != null && H !== null && H.complete && H.naturalHeight !== 0 && H.naturalWidth !== 0;
|
1226
|
+
te && I.excavation != null && ($ = De(
|
1227
|
+
T,
|
1228
|
+
I.excavation
|
1515
1229
|
));
|
1516
|
-
const
|
1517
|
-
|
1518
|
-
const
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1230
|
+
const X = window.devicePixelRatio || 1;
|
1231
|
+
W.height = W.width = h * X;
|
1232
|
+
const G = h / q * X;
|
1233
|
+
O.scale(G, G), O.fillStyle = w, O.fillRect(0, 0, q, q), O.fillStyle = e, Mt ? O.fill(new Path2D(Oe($, x))) : T.forEach(function(oe, re) {
|
1234
|
+
oe.forEach(function(ae, L) {
|
1235
|
+
ae && O.fillRect(L + x, re + x, 1, 1);
|
1522
1236
|
});
|
1523
|
-
}),
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1237
|
+
}), I && (O.globalAlpha = I.opacity), te && O.drawImage(
|
1238
|
+
H,
|
1239
|
+
I.x + x,
|
1240
|
+
I.y + x,
|
1241
|
+
I.w,
|
1242
|
+
I.h
|
1529
1243
|
);
|
1530
1244
|
}
|
1531
|
-
}),
|
1532
|
-
|
1533
|
-
}, [
|
1534
|
-
const
|
1535
|
-
let
|
1536
|
-
return
|
1245
|
+
}), S.useEffect(() => {
|
1246
|
+
V(!1);
|
1247
|
+
}, [v]);
|
1248
|
+
const B = ie({ height: h, width: h }, g);
|
1249
|
+
let ee = null;
|
1250
|
+
return v != null && (ee = /* @__PURE__ */ S.createElement(
|
1537
1251
|
"img",
|
1538
1252
|
{
|
1539
|
-
src:
|
1540
|
-
key:
|
1253
|
+
src: v,
|
1254
|
+
key: v,
|
1541
1255
|
style: { display: "none" },
|
1542
1256
|
onLoad: () => {
|
1543
|
-
|
1257
|
+
V(!0);
|
1544
1258
|
},
|
1545
|
-
ref:
|
1546
|
-
crossOrigin:
|
1259
|
+
ref: j,
|
1260
|
+
crossOrigin: I == null ? void 0 : I.crossOrigin
|
1547
1261
|
}
|
1548
|
-
)), /* @__PURE__ */
|
1262
|
+
)), /* @__PURE__ */ S.createElement(S.Fragment, null, /* @__PURE__ */ S.createElement(
|
1549
1263
|
"canvas",
|
1550
|
-
|
1551
|
-
style:
|
1552
|
-
height:
|
1553
|
-
width:
|
1554
|
-
ref:
|
1264
|
+
ie({
|
1265
|
+
style: B,
|
1266
|
+
height: h,
|
1267
|
+
width: h,
|
1268
|
+
ref: M,
|
1555
1269
|
role: "img"
|
1556
|
-
},
|
1557
|
-
),
|
1270
|
+
}, b)
|
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:
|
1571
|
-
boostLevel:
|
1572
|
-
title:
|
1573
|
-
marginSize:
|
1574
|
-
imageSettings:
|
1575
|
-
} =
|
1274
|
+
kt.displayName = "QRCodeCanvas";
|
1275
|
+
var Ie = S.forwardRef(
|
1276
|
+
function(r, t) {
|
1277
|
+
const c = r, {
|
1278
|
+
value: u,
|
1279
|
+
size: h = Me,
|
1280
|
+
level: y = ke,
|
1281
|
+
bgColor: w = Re,
|
1282
|
+
fgColor: e = Se,
|
1283
|
+
includeMargin: n = Le,
|
1284
|
+
minVersion: o = Pe,
|
1285
|
+
boostLevel: i,
|
1286
|
+
title: l,
|
1287
|
+
marginSize: f,
|
1288
|
+
imageSettings: d
|
1289
|
+
} = c, m = ce(c, [
|
1576
1290
|
"value",
|
1577
1291
|
"size",
|
1578
1292
|
"level",
|
@@ -1584,126 +1298,126 @@ var At = B.forwardRef(
|
|
1584
1298
|
"title",
|
1585
1299
|
"marginSize",
|
1586
1300
|
"imageSettings"
|
1587
|
-
]), { margin:
|
1588
|
-
value:
|
1589
|
-
level:
|
1590
|
-
minVersion:
|
1591
|
-
boostLevel:
|
1592
|
-
includeMargin:
|
1593
|
-
marginSize:
|
1594
|
-
imageSettings:
|
1595
|
-
size:
|
1301
|
+
]), { margin: g, cells: b, numCells: v, calculatedImageSettings: p } = Ue({
|
1302
|
+
value: u,
|
1303
|
+
level: y,
|
1304
|
+
minVersion: o,
|
1305
|
+
boostLevel: i,
|
1306
|
+
includeMargin: n,
|
1307
|
+
marginSize: f,
|
1308
|
+
imageSettings: d,
|
1309
|
+
size: h
|
1596
1310
|
});
|
1597
|
-
let
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
)),
|
1311
|
+
let j = b, M = null;
|
1312
|
+
d != null && p != null && (p.excavation != null && (j = De(
|
1313
|
+
b,
|
1314
|
+
p.excavation
|
1315
|
+
)), M = /* @__PURE__ */ S.createElement(
|
1602
1316
|
"image",
|
1603
1317
|
{
|
1604
|
-
href:
|
1605
|
-
height:
|
1606
|
-
width:
|
1607
|
-
x:
|
1608
|
-
y:
|
1318
|
+
href: d.src,
|
1319
|
+
height: p.h,
|
1320
|
+
width: p.w,
|
1321
|
+
x: p.x + g,
|
1322
|
+
y: p.y + g,
|
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 F = Oe(j, g);
|
1329
|
+
return /* @__PURE__ */ S.createElement(
|
1616
1330
|
"svg",
|
1617
|
-
|
1618
|
-
height:
|
1619
|
-
width:
|
1620
|
-
viewBox: `0 0 ${
|
1621
|
-
ref:
|
1331
|
+
ie({
|
1332
|
+
height: h,
|
1333
|
+
width: h,
|
1334
|
+
viewBox: `0 0 ${v} ${v}`,
|
1335
|
+
ref: t,
|
1622
1336
|
role: "img"
|
1623
|
-
},
|
1624
|
-
!!
|
1625
|
-
/* @__PURE__ */
|
1337
|
+
}, m),
|
1338
|
+
!!l && /* @__PURE__ */ S.createElement("title", null, l),
|
1339
|
+
/* @__PURE__ */ S.createElement(
|
1626
1340
|
"path",
|
1627
1341
|
{
|
1628
|
-
fill:
|
1629
|
-
d: `M0,0 h${
|
1342
|
+
fill: w,
|
1343
|
+
d: `M0,0 h${v}v${v}H0z`,
|
1630
1344
|
shapeRendering: "crispEdges"
|
1631
1345
|
}
|
1632
1346
|
),
|
1633
|
-
/* @__PURE__ */
|
1634
|
-
|
1347
|
+
/* @__PURE__ */ S.createElement("path", { fill: e, d: F, shapeRendering: "crispEdges" }),
|
1348
|
+
M
|
1635
1349
|
);
|
1636
1350
|
}
|
1637
1351
|
);
|
1638
|
-
|
1639
|
-
const
|
1640
|
-
walletAddress:
|
1641
|
-
amount:
|
1642
|
-
currency:
|
1643
|
-
theme:
|
1644
|
-
size:
|
1352
|
+
Ie.displayName = "QRCodeSVG";
|
1353
|
+
const Vt = ({
|
1354
|
+
walletAddress: s,
|
1355
|
+
amount: r,
|
1356
|
+
currency: t,
|
1357
|
+
theme: c = "light",
|
1358
|
+
size: u = 200
|
1645
1359
|
}) => {
|
1646
|
-
const [
|
1647
|
-
|
1648
|
-
if (!
|
1649
|
-
|
1360
|
+
const [h, y] = U(""), [w, e] = U(null);
|
1361
|
+
Z(() => {
|
1362
|
+
if (!s) {
|
1363
|
+
e("No wallet address provided");
|
1650
1364
|
return;
|
1651
1365
|
}
|
1652
1366
|
try {
|
1653
|
-
let
|
1654
|
-
|
1655
|
-
} catch (
|
1656
|
-
console.error("Error generating QR code:",
|
1367
|
+
let l;
|
1368
|
+
t === "SOL" || t === "USDC_SOL" ? l = `solana:${s}?amount=${r}&spl-token=USDC` : t === "USDT" || t === "USDC" ? l = `ethereum:${n(t)}/transfer?address=${s}&uint256=${o(r, t)}` : l = `ethereum:${s}@1?value=${i(r)}`, y(l), e(null);
|
1369
|
+
} catch (l) {
|
1370
|
+
console.error("Error generating QR code:", l), e("Error generating payment QR code");
|
1657
1371
|
}
|
1658
|
-
}, [
|
1659
|
-
const
|
1372
|
+
}, [s, r, t]);
|
1373
|
+
const n = (l) => ({
|
1660
1374
|
USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
1661
1375
|
USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
1662
1376
|
BNB: "0xB8c77482e45F1F44dE1745F52C74426C631bDD52"
|
1663
|
-
})[
|
1664
|
-
const
|
1665
|
-
return Math.floor(parseFloat(
|
1666
|
-
},
|
1667
|
-
return /* @__PURE__ */
|
1668
|
-
|
1669
|
-
|
1377
|
+
})[l] || "", o = (l, f) => {
|
1378
|
+
const d = f === "USDT" || f === "USDC" ? 6 : 18;
|
1379
|
+
return Math.floor(parseFloat(l) * Math.pow(10, d)).toString();
|
1380
|
+
}, i = (l) => Math.floor(parseFloat(l) * 1e18).toString();
|
1381
|
+
return /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col items-center", children: [
|
1382
|
+
w ? /* @__PURE__ */ a.jsx("div", { className: "p-4 rounded-lg bg-red-100 mb-3 text-red-700", children: w }) : /* @__PURE__ */ a.jsx("div", { className: "p-4 rounded-lg bg-white mb-3", children: h && /* @__PURE__ */ a.jsx(
|
1383
|
+
Ie,
|
1670
1384
|
{
|
1671
|
-
value:
|
1672
|
-
size:
|
1673
|
-
bgColor:
|
1674
|
-
fgColor:
|
1385
|
+
value: h,
|
1386
|
+
size: u,
|
1387
|
+
bgColor: c === "dark" ? "#374151" : "#FFFFFF",
|
1388
|
+
fgColor: c === "dark" ? "#FFFFFF" : "#000000",
|
1675
1389
|
level: "H",
|
1676
1390
|
includeMargin: !0
|
1677
1391
|
}
|
1678
1392
|
) }),
|
1679
|
-
/* @__PURE__ */
|
1680
|
-
/* @__PURE__ */
|
1393
|
+
/* @__PURE__ */ a.jsxs("div", { className: "text-center text-sm text-gray-700", children: [
|
1394
|
+
/* @__PURE__ */ a.jsx("p", { className: "font-semibold text-gray-800", children: "Pay with QR Code" }),
|
1681
1395
|
"Scan with your wallet app to pay"
|
1682
1396
|
] }),
|
1683
|
-
/* @__PURE__ */
|
1684
|
-
/* @__PURE__ */
|
1685
|
-
/* @__PURE__ */
|
1686
|
-
/* @__PURE__ */
|
1687
|
-
/* @__PURE__ */
|
1688
|
-
/* @__PURE__ */
|
1689
|
-
/* @__PURE__ */
|
1397
|
+
/* @__PURE__ */ a.jsx("div", { className: "mt-3 w-full" }),
|
1398
|
+
/* @__PURE__ */ a.jsx("div", { className: "mt-4 w-full", children: /* @__PURE__ */ a.jsxs("div", { className: "p-3 rounded bg-gray-100", children: [
|
1399
|
+
/* @__PURE__ */ a.jsx("h4", { className: "text-sm font-medium mb-2 text-gray-800", children: "Payment Instructions" }),
|
1400
|
+
/* @__PURE__ */ a.jsxs("ol", { className: "text-xs space-y-2 text-gray-600", children: [
|
1401
|
+
/* @__PURE__ */ a.jsx("li", { children: "1. Open your crypto wallet app (MetaMask, Trust Wallet, etc.)" }),
|
1402
|
+
/* @__PURE__ */ a.jsx("li", { children: "2. Scan the QR code above" }),
|
1403
|
+
/* @__PURE__ */ a.jsxs("li", { children: [
|
1690
1404
|
"3. Confirm the payment amount (",
|
1691
|
-
|
1405
|
+
r,
|
1692
1406
|
" ",
|
1693
|
-
|
1407
|
+
t,
|
1694
1408
|
")"
|
1695
1409
|
] }),
|
1696
|
-
/* @__PURE__ */
|
1410
|
+
/* @__PURE__ */ a.jsx("li", { children: '4. Click "Pay Now" button below after sending the payment' })
|
1697
1411
|
] })
|
1698
1412
|
] }) })
|
1699
1413
|
] });
|
1700
|
-
},
|
1701
|
-
const
|
1702
|
-
switch (
|
1414
|
+
}, le = ({ status: s, message: r, theme: t = "light" }) => {
|
1415
|
+
const c = () => {
|
1416
|
+
switch (s) {
|
1703
1417
|
case "processing":
|
1704
|
-
return /* @__PURE__ */
|
1418
|
+
return /* @__PURE__ */ a.jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20" });
|
1705
1419
|
case "success":
|
1706
|
-
return /* @__PURE__ */
|
1420
|
+
return /* @__PURE__ */ a.jsx("div", { className: "rounded-full h-12 w-12 bg-green-100 flex items-center justify-center", children: /* @__PURE__ */ a.jsx(
|
1707
1421
|
"svg",
|
1708
1422
|
{
|
1709
1423
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -1712,11 +1426,11 @@ const Kr = ({
|
|
1712
1426
|
viewBox: "0 0 24 24",
|
1713
1427
|
stroke: "currentColor",
|
1714
1428
|
strokeWidth: 2,
|
1715
|
-
children: /* @__PURE__ */
|
1429
|
+
children: /* @__PURE__ */ a.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
|
1716
1430
|
}
|
1717
1431
|
) });
|
1718
1432
|
case "error":
|
1719
|
-
return /* @__PURE__ */
|
1433
|
+
return /* @__PURE__ */ a.jsx("div", { className: "rounded-full h-12 w-12 bg-red-100 flex items-center justify-center", children: /* @__PURE__ */ a.jsx(
|
1720
1434
|
"svg",
|
1721
1435
|
{
|
1722
1436
|
xmlns: "http://www.w3.org/2000/svg",
|
@@ -1725,14 +1439,14 @@ const Kr = ({
|
|
1725
1439
|
viewBox: "0 0 24 24",
|
1726
1440
|
stroke: "currentColor",
|
1727
1441
|
strokeWidth: 2,
|
1728
|
-
children: /* @__PURE__ */
|
1442
|
+
children: /* @__PURE__ */ a.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
1729
1443
|
}
|
1730
1444
|
) });
|
1731
1445
|
default:
|
1732
1446
|
return null;
|
1733
1447
|
}
|
1734
|
-
},
|
1735
|
-
switch (
|
1448
|
+
}, u = () => {
|
1449
|
+
switch (s) {
|
1736
1450
|
case "processing":
|
1737
1451
|
return "Processing Payment";
|
1738
1452
|
case "success":
|
@@ -1742,385 +1456,137 @@ const Kr = ({
|
|
1742
1456
|
default:
|
1743
1457
|
return "Unknown Status";
|
1744
1458
|
}
|
1745
|
-
},
|
1746
|
-
switch (
|
1459
|
+
}, h = () => {
|
1460
|
+
switch (s) {
|
1747
1461
|
case "processing":
|
1748
|
-
return
|
1462
|
+
return t === "dark" ? "text-blue-300" : "text-blue-600";
|
1749
1463
|
case "success":
|
1750
|
-
return
|
1464
|
+
return t === "dark" ? "text-green-300" : "text-green-600";
|
1751
1465
|
case "error":
|
1752
|
-
return
|
1466
|
+
return t === "dark" ? "text-red-300" : "text-red-600";
|
1753
1467
|
default:
|
1754
|
-
return
|
1468
|
+
return t === "dark" ? "text-gray-300" : "text-gray-600";
|
1755
1469
|
}
|
1756
1470
|
};
|
1757
|
-
return /* @__PURE__ */
|
1758
|
-
/* @__PURE__ */
|
1759
|
-
/* @__PURE__ */
|
1760
|
-
/* @__PURE__ */
|
1761
|
-
|
1762
|
-
|
1471
|
+
return /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
|
1472
|
+
/* @__PURE__ */ a.jsx("div", { className: "mb-4", children: c() }),
|
1473
|
+
/* @__PURE__ */ a.jsx("h3", { className: `text-xl font-bold mb-2 ${t === "dark" ? "text-white" : "text-gray-900"}`, children: u() }),
|
1474
|
+
/* @__PURE__ */ a.jsx("p", { className: `text-center ${h()}`, children: r }),
|
1475
|
+
s === "processing" && /* @__PURE__ */ a.jsx("div", { className: `mt-4 text-xs ${t === "dark" ? "text-gray-400" : "text-gray-500"}`, children: "This may take a few moments. Please do not close this window." }),
|
1476
|
+
s === "success" && /* @__PURE__ */ a.jsx("div", { className: `mt-4 p-2 rounded ${t === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: /* @__PURE__ */ a.jsx("p", { className: `text-xs ${t === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Your payment has been successfully processed. You will receive a confirmation shortly." }) })
|
1763
1477
|
] });
|
1764
|
-
},
|
1765
|
-
|
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());
|
1478
|
+
}, Rt = ({ onSelect: s, selected: r, theme: t = "light", supportedNetworks: c = [] }) => {
|
1479
|
+
const [u, h] = U({}), [y, w] = U(A.ETHEREUM);
|
1480
|
+
Z(() => {
|
1481
|
+
h(ue());
|
2016
1482
|
}, []);
|
2017
|
-
const
|
1483
|
+
const e = [
|
2018
1484
|
{
|
2019
1485
|
id: "USDT",
|
2020
1486
|
name: "USDT",
|
2021
1487
|
description: "Tether USD",
|
2022
1488
|
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",
|
2023
|
-
networks: [
|
1489
|
+
networks: [A.ETHEREUM, A.BSC, A.TRON]
|
2024
1490
|
},
|
2025
1491
|
{
|
2026
1492
|
id: "USDC",
|
2027
1493
|
name: "USDC",
|
2028
1494
|
description: "USD Coin",
|
2029
1495
|
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",
|
2030
|
-
networks: [
|
1496
|
+
networks: [A.ETHEREUM, A.BSC, A.TRON]
|
2031
1497
|
},
|
2032
1498
|
{
|
2033
1499
|
id: "BNB",
|
2034
1500
|
name: "BNB",
|
2035
1501
|
description: "Binance Coin",
|
2036
1502
|
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",
|
2037
|
-
networks: [
|
1503
|
+
networks: [A.BSC]
|
2038
1504
|
},
|
2039
1505
|
{
|
2040
1506
|
id: "ETH",
|
2041
1507
|
name: "ETH",
|
2042
1508
|
description: "Ethereum",
|
2043
1509
|
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",
|
2044
|
-
networks: [
|
1510
|
+
networks: [A.ETHEREUM]
|
2045
1511
|
},
|
2046
1512
|
{
|
2047
1513
|
id: "TRX",
|
2048
1514
|
name: "TRX",
|
2049
1515
|
description: "Tron",
|
2050
1516
|
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",
|
2051
|
-
networks: [
|
1517
|
+
networks: [A.TRON]
|
2052
1518
|
},
|
2053
1519
|
{
|
2054
1520
|
id: "ALGO",
|
2055
1521
|
name: "ALGO",
|
2056
1522
|
description: "Algorand",
|
2057
1523
|
logo: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR0Yx1Vp8qPQI5XZoJuKfQS8bj_FNiMZGCHqA&s",
|
2058
|
-
networks: [
|
2059
|
-
}
|
2060
|
-
],
|
2061
|
-
const
|
2062
|
-
return
|
2063
|
-
},
|
2064
|
-
[
|
2065
|
-
[
|
2066
|
-
[
|
2067
|
-
[
|
2068
|
-
})[
|
2069
|
-
var
|
2070
|
-
|
2071
|
-
currency:
|
2072
|
-
network:
|
2073
|
-
tokenConfig: (
|
1524
|
+
networks: [A.ALGORAND]
|
1525
|
+
}
|
1526
|
+
], n = e.filter((d) => c.length === 0 ? !0 : d.networks.some((m) => c.includes(m))), o = (d) => {
|
1527
|
+
const m = e.find((g) => g.id === d);
|
1528
|
+
return m ? m.networks : [];
|
1529
|
+
}, i = (d) => ({
|
1530
|
+
[A.ETHEREUM]: "Ethereum",
|
1531
|
+
[A.BSC]: "BSC",
|
1532
|
+
[A.TRON]: "Tron",
|
1533
|
+
[A.ALGORAND]: "Algorand"
|
1534
|
+
})[d] || d, l = (d) => Ne(d).length > 0, f = (d, m) => {
|
1535
|
+
var g;
|
1536
|
+
w(m), s({
|
1537
|
+
currency: d,
|
1538
|
+
network: m,
|
1539
|
+
tokenConfig: (g = Xe[d]) == null ? void 0 : g[m]
|
2074
1540
|
});
|
2075
1541
|
};
|
2076
|
-
return /* @__PURE__ */
|
2077
|
-
/* @__PURE__ */
|
2078
|
-
/* @__PURE__ */
|
2079
|
-
const
|
2080
|
-
return /* @__PURE__ */
|
2081
|
-
/* @__PURE__ */
|
2082
|
-
/* @__PURE__ */
|
2083
|
-
/* @__PURE__ */
|
2084
|
-
/* @__PURE__ */
|
2085
|
-
/* @__PURE__ */
|
1542
|
+
return /* @__PURE__ */ a.jsxs("div", { children: [
|
1543
|
+
/* @__PURE__ */ a.jsx("h3", { className: `text-lg font-medium mb-3 ${t === "dark" ? "text-white" : "text-gray-800"}`, children: "Select Payment Method" }),
|
1544
|
+
/* @__PURE__ */ a.jsx("div", { className: "space-y-3", children: n.map((d) => {
|
1545
|
+
const m = o(d.id), g = (r == null ? void 0 : r.currency) === d.id;
|
1546
|
+
return /* @__PURE__ */ a.jsxs("div", { className: "space-y-2", children: [
|
1547
|
+
/* @__PURE__ */ a.jsxs("div", { className: `flex items-center p-3 rounded-lg border-2 transition-colors ${g ? t === "dark" ? "bg-blue-900/30 border-[#7042D2]" : "bg-blue-50 border-[#7042D2]" : t === "dark" ? "bg-gray-700 border-gray-700" : "bg-white border-gray-200"}`, children: [
|
1548
|
+
/* @__PURE__ */ a.jsx("div", { className: "flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mr-3", children: /* @__PURE__ */ a.jsx("img", { src: d.logo, alt: d.name, className: "h-6 w-6" }) }),
|
1549
|
+
/* @__PURE__ */ a.jsxs("div", { className: "flex-1", children: [
|
1550
|
+
/* @__PURE__ */ a.jsx("h4", { className: `font-medium ${t === "dark" ? "text-white" : "text-gray-900"}`, children: d.name }),
|
1551
|
+
/* @__PURE__ */ a.jsx("p", { className: `text-sm ${t === "dark" ? "text-gray-300" : "text-gray-500"}`, children: d.description })
|
2086
1552
|
] })
|
2087
1553
|
] }),
|
2088
|
-
|
2089
|
-
/* @__PURE__ */
|
2090
|
-
/* @__PURE__ */
|
2091
|
-
const
|
2092
|
-
return /* @__PURE__ */
|
1554
|
+
m.length > 1 && /* @__PURE__ */ a.jsxs("div", { className: "ml-4 space-y-2", children: [
|
1555
|
+
/* @__PURE__ */ a.jsx("p", { className: `text-sm font-medium ${t === "dark" ? "text-gray-300" : "text-gray-700"}`, children: "Select Network:" }),
|
1556
|
+
/* @__PURE__ */ a.jsx("div", { className: "grid grid-cols-2 gap-2", children: m.map((b) => {
|
1557
|
+
const v = g && (r == null ? void 0 : r.network) === b, p = l(b);
|
1558
|
+
return /* @__PURE__ */ a.jsx(
|
2093
1559
|
"button",
|
2094
1560
|
{
|
2095
|
-
onClick: () =>
|
2096
|
-
disabled: !
|
2097
|
-
className: `p-2 rounded-md text-sm font-medium transition-colors ${
|
2098
|
-
children: /* @__PURE__ */
|
2099
|
-
/* @__PURE__ */
|
2100
|
-
!
|
1561
|
+
onClick: () => f(d.id, b),
|
1562
|
+
disabled: !p,
|
1563
|
+
className: `p-2 rounded-md text-sm font-medium transition-colors ${v ? "bg-[#7042D2] text-white" : p ? t === "dark" ? "bg-gray-600 text-gray-200 hover:bg-gray-500" : "bg-gray-100 text-gray-700 hover:bg-gray-200" : t === "dark" ? "bg-gray-800 text-gray-500 cursor-not-allowed" : "bg-gray-50 text-gray-400 cursor-not-allowed"}`,
|
1564
|
+
children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-center space-x-1", children: [
|
1565
|
+
/* @__PURE__ */ a.jsx("span", { children: i(b) }),
|
1566
|
+
!p && /* @__PURE__ */ a.jsx("span", { className: "text-xs", children: "(No wallet)" })
|
2101
1567
|
] })
|
2102
1568
|
},
|
2103
|
-
|
1569
|
+
b
|
2104
1570
|
);
|
2105
1571
|
}) })
|
2106
1572
|
] }),
|
2107
|
-
|
1573
|
+
m.length === 1 && /* @__PURE__ */ a.jsx("div", { className: "ml-4", children: /* @__PURE__ */ a.jsx(
|
2108
1574
|
"button",
|
2109
1575
|
{
|
2110
|
-
onClick: () =>
|
2111
|
-
disabled: !
|
2112
|
-
className: `w-full p-2 rounded-md text-sm font-medium transition-colors ${
|
2113
|
-
children: /* @__PURE__ */
|
2114
|
-
/* @__PURE__ */
|
2115
|
-
!
|
2116
|
-
|
1576
|
+
onClick: () => f(d.id, m[0]),
|
1577
|
+
disabled: !l(m[0]),
|
1578
|
+
className: `w-full p-2 rounded-md text-sm font-medium transition-colors ${g ? "bg-[#7042D2] text-white" : l(m[0]) ? t === "dark" ? "bg-gray-600 text-gray-200 hover:bg-gray-500" : "bg-gray-100 text-gray-700 hover:bg-gray-200" : t === "dark" ? "bg-gray-800 text-gray-500 cursor-not-allowed" : "bg-gray-50 text-gray-400 cursor-not-allowed"}`,
|
1579
|
+
children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-between", children: [
|
1580
|
+
/* @__PURE__ */ a.jsx("span", { children: i(m[0]) }),
|
1581
|
+
!l(m[0]) && /* @__PURE__ */ a.jsx("span", { className: "text-xs", children: "No wallet detected" }),
|
1582
|
+
g && /* @__PURE__ */ a.jsx(
|
2117
1583
|
"svg",
|
2118
1584
|
{
|
2119
1585
|
xmlns: "http://www.w3.org/2000/svg",
|
2120
1586
|
className: "h-4 w-4",
|
2121
1587
|
viewBox: "0 0 20 20",
|
2122
1588
|
fill: "currentColor",
|
2123
|
-
children: /* @__PURE__ */
|
1589
|
+
children: /* @__PURE__ */ a.jsx(
|
2124
1590
|
"path",
|
2125
1591
|
{
|
2126
1592
|
fillRule: "evenodd",
|
@@ -2133,231 +1599,231 @@ const Nr = () => G(void 0, null, function* () {
|
|
2133
1599
|
] })
|
2134
1600
|
}
|
2135
1601
|
) })
|
2136
|
-
] },
|
1602
|
+
] }, d.id);
|
2137
1603
|
}) }),
|
2138
|
-
/* @__PURE__ */
|
2139
|
-
/* @__PURE__ */
|
2140
|
-
/* @__PURE__ */
|
2141
|
-
/* @__PURE__ */
|
2142
|
-
/* @__PURE__ */
|
2143
|
-
] },
|
1604
|
+
/* @__PURE__ */ a.jsxs("div", { className: "mt-4 p-3 rounded-lg bg-gray-50 dark:bg-gray-800", children: [
|
1605
|
+
/* @__PURE__ */ a.jsx("h4", { className: `text-sm font-medium mb-2 ${t === "dark" ? "text-white" : "text-gray-800"}`, children: "Detected Wallets:" }),
|
1606
|
+
/* @__PURE__ */ a.jsx("div", { className: "space-y-1", children: Object.entries(u).map(([d, m]) => /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-between text-xs", children: [
|
1607
|
+
/* @__PURE__ */ a.jsx("span", { className: `capitalize ${t === "dark" ? "text-gray-300" : "text-gray-600"}`, children: d.replace("_", " ") }),
|
1608
|
+
/* @__PURE__ */ a.jsx("span", { className: `px-2 py-1 rounded-full ${m ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800"}`, children: m ? "Available" : "Not detected" })
|
1609
|
+
] }, d)) })
|
2144
1610
|
] })
|
2145
1611
|
] });
|
2146
|
-
},
|
2147
|
-
isOpen:
|
2148
|
-
onClose:
|
2149
|
-
payment:
|
2150
|
-
paymentStatus:
|
2151
|
-
selectedPaymentMethod:
|
2152
|
-
onPaymentMethodSelect:
|
2153
|
-
onPayment:
|
2154
|
-
onBack:
|
2155
|
-
error:
|
2156
|
-
theme:
|
2157
|
-
merchantName:
|
2158
|
-
transactionHash:
|
2159
|
-
walletConnection:
|
2160
|
-
onConnectWallet:
|
2161
|
-
testMode:
|
2162
|
-
supportedNetworks:
|
2163
|
-
availableWallets:
|
2164
|
-
supportedWallets:
|
2165
|
-
step:
|
1612
|
+
}, St = "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==", Lt = ({
|
1613
|
+
isOpen: s,
|
1614
|
+
onClose: r,
|
1615
|
+
payment: t,
|
1616
|
+
paymentStatus: c,
|
1617
|
+
selectedPaymentMethod: u,
|
1618
|
+
onPaymentMethodSelect: h,
|
1619
|
+
onPayment: y,
|
1620
|
+
onBack: w,
|
1621
|
+
error: e,
|
1622
|
+
theme: n = "light",
|
1623
|
+
merchantName: o,
|
1624
|
+
transactionHash: i,
|
1625
|
+
walletConnection: l,
|
1626
|
+
onConnectWallet: f,
|
1627
|
+
testMode: d = !1,
|
1628
|
+
supportedNetworks: m = [],
|
1629
|
+
availableWallets: g = {},
|
1630
|
+
supportedWallets: b = [],
|
1631
|
+
step: v = "select-currency"
|
2166
1632
|
}) => {
|
2167
|
-
const
|
1633
|
+
const p = (x) => parseFloat(x).toFixed(2), j = (x) => x ? x.length <= 14 ? x : `${x.slice(0, 8)}...${x.slice(-6)}` : "", M = (x) => ({
|
2168
1634
|
ethereum: "Ethereum",
|
2169
1635
|
bsc: "BSC",
|
2170
1636
|
tron: "Tron",
|
2171
1637
|
algorand: "Algorand"
|
2172
|
-
})[
|
2173
|
-
[
|
2174
|
-
[
|
2175
|
-
[
|
2176
|
-
[
|
2177
|
-
})[
|
2178
|
-
[
|
2179
|
-
[
|
2180
|
-
[
|
2181
|
-
[
|
2182
|
-
})[
|
2183
|
-
return
|
2184
|
-
/* @__PURE__ */
|
2185
|
-
/* @__PURE__ */
|
2186
|
-
/* @__PURE__ */
|
1638
|
+
})[x] || x, F = (x) => ({
|
1639
|
+
[N.METAMASK]: "MetaMask",
|
1640
|
+
[N.TRONLINK]: "TronLink",
|
1641
|
+
[N.TRUST_WALLET]: "Trust Wallet",
|
1642
|
+
[N.LUTE]: "Lute Wallet"
|
1643
|
+
})[x] || x, V = (x) => ({
|
1644
|
+
[N.METAMASK]: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",
|
1645
|
+
[N.TRONLINK]: "https://www.tronlink.org/images/logo.png",
|
1646
|
+
[N.TRUST_WALLET]: "https://trustwallet.com/assets/images/trust_logotype.svg",
|
1647
|
+
[N.LUTE]: "https://lute.app/logo.png"
|
1648
|
+
})[x] || "";
|
1649
|
+
return s ? /* @__PURE__ */ a.jsx("div", { className: "fixed inset-0 z-50 overflow-y-auto bg-black/50", children: /* @__PURE__ */ a.jsx("div", { className: "flex min-h-screen items-center justify-center p-4", children: /* @__PURE__ */ a.jsxs("div", { className: "relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800", children: [
|
1650
|
+
/* @__PURE__ */ a.jsxs("div", { className: "flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl", children: [
|
1651
|
+
/* @__PURE__ */ a.jsx("div", { className: "flex items-center", children: /* @__PURE__ */ a.jsx("h2", { className: "text-xl font-bold text-gray-900", children: /* @__PURE__ */ a.jsx("img", { src: St, className: "w-32", alt: "Coinley Logo" }) }) }),
|
1652
|
+
/* @__PURE__ */ a.jsx(
|
2187
1653
|
"button",
|
2188
1654
|
{
|
2189
|
-
onClick:
|
1655
|
+
onClick: r,
|
2190
1656
|
className: "text-gray-500 hover:text-gray-700 focus:outline-none",
|
2191
|
-
children: /* @__PURE__ */
|
1657
|
+
children: /* @__PURE__ */ a.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__ */ a.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
2192
1658
|
}
|
2193
1659
|
)
|
2194
1660
|
] }),
|
2195
|
-
/* @__PURE__ */
|
2196
|
-
|
2197
|
-
/* @__PURE__ */
|
1661
|
+
/* @__PURE__ */ a.jsxs("div", { className: "mb-6 bg-[#F1ECFB] p-3 rounded-xl", children: [
|
1662
|
+
t && /* @__PURE__ */ a.jsxs("div", { className: "mb-6 p-4 rounded-lg", children: [
|
1663
|
+
/* @__PURE__ */ a.jsxs("p", { className: "text-lg text-gray-800 font-semibold", children: [
|
2198
1664
|
"PAY: ",
|
2199
|
-
|
1665
|
+
o
|
2200
1666
|
] }),
|
2201
|
-
/* @__PURE__ */
|
2202
|
-
/* @__PURE__ */
|
2203
|
-
/* @__PURE__ */
|
1667
|
+
/* @__PURE__ */ a.jsxs("div", { className: "flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg", children: [
|
1668
|
+
/* @__PURE__ */ a.jsx("span", { className: "font-medium text-gray-700", children: "Amount:" }),
|
1669
|
+
/* @__PURE__ */ a.jsxs("span", { className: "font-bold text-xl text-[#7042D2]", children: [
|
2204
1670
|
"$",
|
2205
|
-
|
1671
|
+
p(t.totalAmount || t.amount)
|
2206
1672
|
] })
|
2207
1673
|
] }),
|
2208
|
-
/* @__PURE__ */
|
1674
|
+
/* @__PURE__ */ a.jsx("div", { className: "text-xs mt-1 text-right", children: /* @__PURE__ */ a.jsxs("span", { className: "text-gray-500", children: [
|
2209
1675
|
"Payment ID: ",
|
2210
|
-
|
1676
|
+
t.id ? t.id.slice(0, 8) : "",
|
2211
1677
|
"..."
|
2212
1678
|
] }) })
|
2213
1679
|
] }),
|
2214
|
-
|
2215
|
-
|
1680
|
+
v === "select-currency" && /* @__PURE__ */ a.jsx(
|
1681
|
+
Rt,
|
2216
1682
|
{
|
2217
|
-
onSelect:
|
2218
|
-
selected:
|
2219
|
-
theme:
|
2220
|
-
supportedNetworks:
|
1683
|
+
onSelect: h,
|
1684
|
+
selected: u,
|
1685
|
+
theme: n,
|
1686
|
+
supportedNetworks: m
|
2221
1687
|
}
|
2222
1688
|
),
|
2223
|
-
|
2224
|
-
/* @__PURE__ */
|
2225
|
-
/* @__PURE__ */
|
2226
|
-
/* @__PURE__ */
|
2227
|
-
/* @__PURE__ */
|
2228
|
-
/* @__PURE__ */
|
2229
|
-
/* @__PURE__ */
|
1689
|
+
v === "confirm" && u && t && /* @__PURE__ */ a.jsxs("div", { children: [
|
1690
|
+
/* @__PURE__ */ a.jsxs("div", { className: "p-4 rounded-lg mb-4 bg-gray-100", children: [
|
1691
|
+
/* @__PURE__ */ a.jsx("h3", { className: "text-lg font-medium mb-2 text-gray-800", children: "Payment Details" }),
|
1692
|
+
/* @__PURE__ */ a.jsxs("div", { className: "space-y-2", children: [
|
1693
|
+
/* @__PURE__ */ a.jsxs("div", { className: "flex justify-between", children: [
|
1694
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Currency:" }),
|
1695
|
+
/* @__PURE__ */ a.jsx("span", { className: "font-medium", children: u.currency })
|
2230
1696
|
] }),
|
2231
|
-
/* @__PURE__ */
|
2232
|
-
/* @__PURE__ */
|
2233
|
-
/* @__PURE__ */
|
1697
|
+
/* @__PURE__ */ a.jsxs("div", { className: "flex justify-between", children: [
|
1698
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Network:" }),
|
1699
|
+
/* @__PURE__ */ a.jsx("span", { className: "font-medium", children: M(u.network) })
|
2234
1700
|
] }),
|
2235
|
-
/* @__PURE__ */
|
2236
|
-
/* @__PURE__ */
|
2237
|
-
/* @__PURE__ */
|
1701
|
+
/* @__PURE__ */ a.jsxs("div", { className: "flex justify-between", children: [
|
1702
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-[#7042D2] font-semibold", children: "Fee:" }),
|
1703
|
+
/* @__PURE__ */ a.jsx("span", { className: "font-medium", children: "1.75%" })
|
2238
1704
|
] })
|
2239
1705
|
] })
|
2240
1706
|
] }),
|
2241
|
-
|
1707
|
+
d ? (
|
2242
1708
|
// Test mode payment option
|
2243
|
-
/* @__PURE__ */
|
2244
|
-
/* @__PURE__ */
|
2245
|
-
/* @__PURE__ */
|
2246
|
-
/* @__PURE__ */
|
2247
|
-
/* @__PURE__ */
|
1709
|
+
/* @__PURE__ */ a.jsx("div", { className: "p-4 rounded-lg mb-4 bg-blue-50", children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center", children: [
|
1710
|
+
/* @__PURE__ */ a.jsx("div", { className: "bg-[#7042D2] rounded-full p-2 mr-3", children: /* @__PURE__ */ a.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__ */ a.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }) }),
|
1711
|
+
/* @__PURE__ */ a.jsxs("div", { children: [
|
1712
|
+
/* @__PURE__ */ a.jsx("h3", { className: "font-medium text-gray-800", children: "Test Mode Payment" }),
|
1713
|
+
/* @__PURE__ */ a.jsx("p", { className: "text-sm text-gray-600", children: 'Click "Pay Now" to simulate a successful payment' })
|
2248
1714
|
] })
|
2249
1715
|
] }) })
|
2250
1716
|
) : (
|
2251
1717
|
// Real wallet connection
|
2252
|
-
/* @__PURE__ */
|
2253
|
-
/* @__PURE__ */
|
2254
|
-
|
2255
|
-
/* @__PURE__ */
|
2256
|
-
/* @__PURE__ */
|
2257
|
-
/* @__PURE__ */
|
2258
|
-
/* @__PURE__ */
|
1718
|
+
/* @__PURE__ */ a.jsxs("div", { className: "space-y-3", children: [
|
1719
|
+
/* @__PURE__ */ a.jsx("h4", { className: "font-medium text-gray-800", children: "Select Wallet:" }),
|
1720
|
+
b.length === 0 ? /* @__PURE__ */ a.jsx("div", { className: "p-4 rounded-lg bg-yellow-50", children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center", children: [
|
1721
|
+
/* @__PURE__ */ a.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__ */ a.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" }) }),
|
1722
|
+
/* @__PURE__ */ a.jsxs("div", { children: [
|
1723
|
+
/* @__PURE__ */ a.jsx("h3", { className: "font-medium text-gray-800", children: "No Compatible Wallets" }),
|
1724
|
+
/* @__PURE__ */ a.jsxs("p", { className: "text-sm text-gray-600", children: [
|
2259
1725
|
"No wallets detected for ",
|
2260
|
-
|
1726
|
+
M(u.network),
|
2261
1727
|
" network"
|
2262
1728
|
] })
|
2263
1729
|
] })
|
2264
|
-
] }) }) :
|
2265
|
-
/* @__PURE__ */
|
2266
|
-
/* @__PURE__ */
|
1730
|
+
] }) }) : b.map((x) => /* @__PURE__ */ a.jsx("div", { className: "p-4 rounded-lg bg-blue-50", children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-between", children: [
|
1731
|
+
/* @__PURE__ */ a.jsxs("div", { className: "flex items-center", children: [
|
1732
|
+
/* @__PURE__ */ a.jsx(
|
2267
1733
|
"img",
|
2268
1734
|
{
|
2269
|
-
src:
|
2270
|
-
alt:
|
1735
|
+
src: V(x),
|
1736
|
+
alt: F(x),
|
2271
1737
|
className: "w-8 h-8 mr-2",
|
2272
|
-
onError: (
|
2273
|
-
|
1738
|
+
onError: (T) => {
|
1739
|
+
T.target.style.display = "none";
|
2274
1740
|
}
|
2275
1741
|
}
|
2276
1742
|
),
|
2277
|
-
/* @__PURE__ */
|
2278
|
-
/* @__PURE__ */
|
2279
|
-
/* @__PURE__ */
|
1743
|
+
/* @__PURE__ */ a.jsxs("div", { children: [
|
1744
|
+
/* @__PURE__ */ a.jsx("h3", { className: "font-medium text-gray-800", children: F(x) }),
|
1745
|
+
/* @__PURE__ */ a.jsxs("p", { className: "text-sm text-gray-600", children: [
|
2280
1746
|
"Pay with ",
|
2281
|
-
|
1747
|
+
F(x)
|
2282
1748
|
] })
|
2283
1749
|
] })
|
2284
1750
|
] }),
|
2285
|
-
(
|
2286
|
-
/* @__PURE__ */
|
2287
|
-
/* @__PURE__ */
|
2288
|
-
] }) : /* @__PURE__ */
|
1751
|
+
(l == null ? void 0 : l.walletType) === x ? /* @__PURE__ */ a.jsxs("div", { className: "flex items-center space-x-2", children: [
|
1752
|
+
/* @__PURE__ */ a.jsx("div", { className: "w-2 h-2 bg-green-500 rounded-full" }),
|
1753
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-sm text-green-600", children: "Connected" })
|
1754
|
+
] }) : /* @__PURE__ */ a.jsx(
|
2289
1755
|
"button",
|
2290
1756
|
{
|
2291
|
-
onClick: () =>
|
1757
|
+
onClick: () => f(x),
|
2292
1758
|
className: "py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",
|
2293
1759
|
children: "Connect"
|
2294
1760
|
}
|
2295
1761
|
)
|
2296
|
-
] }) },
|
2297
|
-
/* @__PURE__ */
|
2298
|
-
/* @__PURE__ */
|
2299
|
-
|
1762
|
+
] }) }, x)),
|
1763
|
+
/* @__PURE__ */ a.jsx("div", { className: "space-y-2", children: Object.entries(g).filter(([x, T]) => !T).map(([x]) => /* @__PURE__ */ a.jsx("div", { className: "p-3 rounded-lg bg-gray-50", children: /* @__PURE__ */ a.jsxs("div", { className: "flex items-center justify-between", children: [
|
1764
|
+
/* @__PURE__ */ a.jsxs("span", { className: "text-sm text-gray-600", children: [
|
1765
|
+
F(x),
|
2300
1766
|
" not detected"
|
2301
1767
|
] }),
|
2302
|
-
/* @__PURE__ */
|
1768
|
+
/* @__PURE__ */ a.jsx(
|
2303
1769
|
"a",
|
2304
1770
|
{
|
2305
|
-
href:
|
1771
|
+
href: ct(x),
|
2306
1772
|
target: "_blank",
|
2307
1773
|
rel: "noopener noreferrer",
|
2308
1774
|
className: "text-sm text-[#7042D2] hover:underline",
|
2309
1775
|
children: "Install"
|
2310
1776
|
}
|
2311
1777
|
)
|
2312
|
-
] }) },
|
1778
|
+
] }) }, x)) })
|
2313
1779
|
] })
|
2314
1780
|
),
|
2315
|
-
/* @__PURE__ */
|
2316
|
-
/* @__PURE__ */
|
1781
|
+
/* @__PURE__ */ a.jsxs("div", { className: "mt-6 grid grid-cols-2 gap-3", children: [
|
1782
|
+
/* @__PURE__ */ a.jsx(
|
2317
1783
|
"button",
|
2318
1784
|
{
|
2319
1785
|
type: "button",
|
2320
|
-
onClick:
|
1786
|
+
onClick: w,
|
2321
1787
|
className: "w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",
|
2322
1788
|
children: "Back"
|
2323
1789
|
}
|
2324
1790
|
),
|
2325
|
-
/* @__PURE__ */
|
1791
|
+
/* @__PURE__ */ a.jsx(
|
2326
1792
|
"button",
|
2327
1793
|
{
|
2328
1794
|
type: "button",
|
2329
|
-
onClick:
|
1795
|
+
onClick: y,
|
2330
1796
|
className: "w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",
|
2331
|
-
disabled: !
|
1797
|
+
disabled: !d && !l,
|
2332
1798
|
children: "Pay Now"
|
2333
1799
|
}
|
2334
1800
|
)
|
2335
1801
|
] })
|
2336
1802
|
] }),
|
2337
|
-
|
2338
|
-
|
1803
|
+
v === "processing" && /* @__PURE__ */ a.jsx(
|
1804
|
+
le,
|
2339
1805
|
{
|
2340
1806
|
status: "processing",
|
2341
|
-
theme:
|
1807
|
+
theme: n,
|
2342
1808
|
message: "Processing your payment..."
|
2343
1809
|
}
|
2344
1810
|
),
|
2345
|
-
|
2346
|
-
/* @__PURE__ */
|
2347
|
-
|
1811
|
+
v === "success" && /* @__PURE__ */ a.jsxs("div", { children: [
|
1812
|
+
/* @__PURE__ */ a.jsx(
|
1813
|
+
le,
|
2348
1814
|
{
|
2349
1815
|
status: "success",
|
2350
|
-
theme:
|
1816
|
+
theme: n,
|
2351
1817
|
message: "Payment successful!"
|
2352
1818
|
}
|
2353
1819
|
),
|
2354
|
-
|
2355
|
-
/* @__PURE__ */
|
2356
|
-
/* @__PURE__ */
|
2357
|
-
|
1820
|
+
i && /* @__PURE__ */ a.jsxs("div", { className: "mt-4 p-3 rounded-lg bg-gray-100", children: [
|
1821
|
+
/* @__PURE__ */ a.jsx("p", { className: "text-xs text-gray-600 mb-1", children: "Transaction Hash:" }),
|
1822
|
+
/* @__PURE__ */ a.jsx("p", { className: "text-sm font-mono break-all text-gray-800", children: j(i) }),
|
1823
|
+
u && /* @__PURE__ */ a.jsx(
|
2358
1824
|
"a",
|
2359
1825
|
{
|
2360
|
-
href: `${
|
1826
|
+
href: `${Pt(u.network)}/tx/${i}`,
|
2361
1827
|
target: "_blank",
|
2362
1828
|
rel: "noopener noreferrer",
|
2363
1829
|
className: "text-xs text-[#7042D2] mt-2 inline-block",
|
@@ -2366,207 +1832,220 @@ const Nr = () => G(void 0, null, function* () {
|
|
2366
1832
|
)
|
2367
1833
|
] })
|
2368
1834
|
] }),
|
2369
|
-
|
2370
|
-
/* @__PURE__ */
|
2371
|
-
|
1835
|
+
v === "error" && /* @__PURE__ */ a.jsxs("div", { children: [
|
1836
|
+
/* @__PURE__ */ a.jsx(
|
1837
|
+
le,
|
2372
1838
|
{
|
2373
1839
|
status: "error",
|
2374
|
-
theme:
|
2375
|
-
message:
|
1840
|
+
theme: n,
|
1841
|
+
message: e || "An error occurred while processing your payment."
|
2376
1842
|
}
|
2377
1843
|
),
|
2378
|
-
/* @__PURE__ */
|
1844
|
+
/* @__PURE__ */ a.jsx(
|
2379
1845
|
"button",
|
2380
1846
|
{
|
2381
1847
|
type: "button",
|
2382
|
-
onClick:
|
1848
|
+
onClick: w,
|
2383
1849
|
className: "mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",
|
2384
1850
|
children: "Try Again"
|
2385
1851
|
}
|
2386
1852
|
)
|
2387
1853
|
] })
|
2388
1854
|
] }),
|
2389
|
-
/* @__PURE__ */
|
1855
|
+
/* @__PURE__ */ a.jsx("div", { className: "text-center text-xs text-gray-500", children: /* @__PURE__ */ a.jsxs("p", { children: [
|
2390
1856
|
"Powered by ",
|
2391
|
-
/* @__PURE__ */
|
1857
|
+
/* @__PURE__ */ a.jsx("span", { className: "text-[#7042D2]", children: "Coinley" }),
|
2392
1858
|
" - Secure Cryptocurrency Payments"
|
2393
1859
|
] }) })
|
2394
1860
|
] }) }) }) : null;
|
2395
|
-
},
|
1861
|
+
}, Pt = (s) => ({
|
2396
1862
|
ethereum: "https://etherscan.io",
|
2397
1863
|
bsc: "https://bscscan.com",
|
2398
1864
|
tron: "https://tronscan.org",
|
2399
1865
|
algorand: "https://algoexplorer.io"
|
2400
|
-
})[
|
2401
|
-
apiKey:
|
2402
|
-
apiSecret:
|
2403
|
-
apiUrl:
|
2404
|
-
customerEmail:
|
2405
|
-
merchantName:
|
2406
|
-
merchantWalletAddresses:
|
1866
|
+
})[s] || "https://etherscan.io", Ot = Ye(({
|
1867
|
+
apiKey: s,
|
1868
|
+
apiSecret: r,
|
1869
|
+
apiUrl: t,
|
1870
|
+
customerEmail: c,
|
1871
|
+
merchantName: u = "Merchant",
|
1872
|
+
merchantWalletAddresses: h = {},
|
2407
1873
|
// Object with network-specific addresses
|
2408
|
-
onSuccess:
|
2409
|
-
onError:
|
2410
|
-
onClose:
|
2411
|
-
theme:
|
2412
|
-
autoOpen:
|
2413
|
-
debug:
|
2414
|
-
testMode:
|
2415
|
-
supportedNetworks:
|
1874
|
+
onSuccess: y,
|
1875
|
+
onError: w,
|
1876
|
+
onClose: e,
|
1877
|
+
theme: n,
|
1878
|
+
autoOpen: o = !1,
|
1879
|
+
debug: i = !1,
|
1880
|
+
testMode: l = !1,
|
1881
|
+
supportedNetworks: f = [],
|
2416
1882
|
// Array of supported networks
|
2417
|
-
preferredNetwork:
|
2418
|
-
preferredWallet:
|
2419
|
-
},
|
2420
|
-
const
|
2421
|
-
|
2422
|
-
const
|
2423
|
-
|
2424
|
-
open: (
|
2425
|
-
|
1883
|
+
preferredNetwork: d = A.ETHEREUM,
|
1884
|
+
preferredWallet: m = N.METAMASK
|
1885
|
+
}, g) => {
|
1886
|
+
const b = Nt(), { theme: v } = xt(), [p, j] = U(o), [M, F] = U(null), [V, x] = U("idle"), [T, q] = U(null), [I, B] = U(null), [ee, W] = U(null), [O, $] = U(null), [H, te] = U({}), [X, G] = U("select-currency");
|
1887
|
+
s || (b == null || b.apiKey), r || (b == null || b.apiSecret), t || (b == null || b.apiUrl);
|
1888
|
+
const oe = n || v, re = i || (b == null ? void 0 : b.debug), ae = f.length > 0 ? f : [A.ETHEREUM, A.BSC, A.TRON, A.ALGORAND];
|
1889
|
+
Je(g, () => ({
|
1890
|
+
open: (C) => {
|
1891
|
+
Fe(C);
|
2426
1892
|
},
|
2427
1893
|
close: () => {
|
2428
|
-
|
1894
|
+
he();
|
2429
1895
|
},
|
2430
|
-
getPayment: () =>
|
2431
|
-
getWalletConnection: () =>
|
1896
|
+
getPayment: () => M,
|
1897
|
+
getWalletConnection: () => O
|
2432
1898
|
}));
|
2433
|
-
const
|
2434
|
-
|
1899
|
+
const L = (C, D) => {
|
1900
|
+
re && console.log(`[Coinley SDK] ${C}`, D);
|
2435
1901
|
};
|
2436
|
-
|
1902
|
+
Z(() => {
|
2437
1903
|
if (typeof window != "undefined") {
|
2438
|
-
const
|
2439
|
-
|
1904
|
+
const C = ue();
|
1905
|
+
te(C), L("Available wallets detected:", C);
|
2440
1906
|
}
|
2441
|
-
}, [
|
2442
|
-
const
|
2443
|
-
if (!
|
2444
|
-
|
1907
|
+
}, [re]);
|
1908
|
+
const Fe = (C) => R(void 0, null, function* () {
|
1909
|
+
if (!C || !C.amount) {
|
1910
|
+
B("Payment amount is required"), w && w(new Error("Payment amount is required"));
|
2445
1911
|
return;
|
2446
1912
|
}
|
2447
|
-
|
1913
|
+
x("loading"), j(!0), G("select-currency");
|
2448
1914
|
try {
|
2449
|
-
|
2450
|
-
const
|
2451
|
-
amount:
|
2452
|
-
currency:
|
2453
|
-
network:
|
2454
|
-
customerEmail:
|
2455
|
-
callbackUrl:
|
2456
|
-
metadata:
|
2457
|
-
merchantWalletAddresses:
|
1915
|
+
L("Creating payment with details:", C);
|
1916
|
+
const D = yield ut({
|
1917
|
+
amount: C.amount,
|
1918
|
+
currency: C.currency || "USDT",
|
1919
|
+
network: C.network || d,
|
1920
|
+
customerEmail: C.customerEmail || c,
|
1921
|
+
callbackUrl: C.callbackUrl,
|
1922
|
+
metadata: C.metadata || {},
|
1923
|
+
merchantWalletAddresses: z(z({}, h), C.merchantWalletAddresses)
|
2458
1924
|
});
|
2459
|
-
|
2460
|
-
} catch (
|
2461
|
-
|
2462
|
-
}
|
2463
|
-
}),
|
2464
|
-
|
2465
|
-
},
|
2466
|
-
|
2467
|
-
},
|
2468
|
-
|
2469
|
-
},
|
2470
|
-
if (!
|
2471
|
-
|
1925
|
+
L("Payment created:", D), F(D.payment), x("idle"), B(null), L("Payment created and state updated");
|
1926
|
+
} catch (D) {
|
1927
|
+
L("Error creating payment:", D), B(D.message || "Failed to create payment"), x("error"), w && w(D);
|
1928
|
+
}
|
1929
|
+
}), he = () => {
|
1930
|
+
j(!1), W(null), $(null), q(null), G("select-currency"), e && e();
|
1931
|
+
}, Be = (C) => {
|
1932
|
+
L("Payment method selected:", C), q(C), G("confirm");
|
1933
|
+
}, We = () => {
|
1934
|
+
X === "confirm" && (G("select-currency"), $(null));
|
1935
|
+
}, Qe = (C) => R(void 0, null, function* () {
|
1936
|
+
if (!T) {
|
1937
|
+
B("Please select a payment method first");
|
2472
1938
|
return;
|
2473
1939
|
}
|
2474
1940
|
try {
|
2475
|
-
|
2476
|
-
const
|
2477
|
-
|
2478
|
-
} catch (
|
2479
|
-
|
2480
|
-
}
|
2481
|
-
}),
|
2482
|
-
var
|
2483
|
-
if (!
|
2484
|
-
|
1941
|
+
L("Connecting wallet:", { walletType: C, network: T.network });
|
1942
|
+
const D = yield et(C, T.network);
|
1943
|
+
$(D), B(null), L("Wallet connected successfully:", D);
|
1944
|
+
} catch (D) {
|
1945
|
+
L("Wallet connection error:", D), B(D.message || "Failed to connect wallet");
|
1946
|
+
}
|
1947
|
+
}), ze = () => R(void 0, null, function* () {
|
1948
|
+
var C, D;
|
1949
|
+
if (!M || !T) {
|
1950
|
+
B("Missing payment information");
|
2485
1951
|
return;
|
2486
1952
|
}
|
2487
|
-
if (!
|
2488
|
-
|
1953
|
+
if (!O && !l) {
|
1954
|
+
B("Please connect your wallet first");
|
2489
1955
|
return;
|
2490
1956
|
}
|
2491
|
-
|
1957
|
+
L("Starting payment process..."), x("loading"), W(null);
|
2492
1958
|
try {
|
2493
|
-
let
|
2494
|
-
if (
|
2495
|
-
|
1959
|
+
let Q;
|
1960
|
+
if (l)
|
1961
|
+
L("Test mode: Generating mock transaction..."), Q = `test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2, 10)}`;
|
2496
1962
|
else {
|
2497
|
-
const
|
2498
|
-
if (!
|
2499
|
-
throw new Error(`No merchant wallet address configured for ${
|
2500
|
-
|
2501
|
-
to:
|
2502
|
-
amount:
|
2503
|
-
tokenAddress: (
|
2504
|
-
tokenDecimals: (
|
1963
|
+
const me = h[T.network];
|
1964
|
+
if (!me)
|
1965
|
+
throw new Error(`No merchant wallet address configured for ${T.network}`);
|
1966
|
+
L("Sending transaction through wallet..."), Q = yield ot(O, {
|
1967
|
+
to: me,
|
1968
|
+
amount: M.amount,
|
1969
|
+
tokenAddress: (C = T.tokenConfig) == null ? void 0 : C.address,
|
1970
|
+
tokenDecimals: (D = T.tokenConfig) == null ? void 0 : D.decimals
|
2505
1971
|
});
|
2506
1972
|
}
|
2507
|
-
|
2508
|
-
const
|
2509
|
-
paymentId:
|
2510
|
-
transactionHash:
|
2511
|
-
network:
|
2512
|
-
currency:
|
2513
|
-
senderAddress:
|
1973
|
+
L("Transaction hash:", Q), W(Q), L("Processing payment with backend...");
|
1974
|
+
const He = yield ht({
|
1975
|
+
paymentId: M.id,
|
1976
|
+
transactionHash: Q,
|
1977
|
+
network: T.network,
|
1978
|
+
currency: T.currency,
|
1979
|
+
senderAddress: O == null ? void 0 : O.address
|
2514
1980
|
});
|
2515
|
-
|
2516
|
-
network:
|
2517
|
-
currency:
|
2518
|
-
amount:
|
1981
|
+
L("Payment processed successfully:", He), x("success"), G("success"), y && (L("Calling onSuccess callback..."), y(M.id, Q, {
|
1982
|
+
network: T.network,
|
1983
|
+
currency: T.currency,
|
1984
|
+
amount: M.amount
|
2519
1985
|
}));
|
2520
|
-
} catch (
|
2521
|
-
|
1986
|
+
} catch (Q) {
|
1987
|
+
L("Payment error:", Q), B(Q.message || "Failed to process payment"), x("error"), G("error"), w && w(Q);
|
2522
1988
|
}
|
2523
|
-
}),
|
2524
|
-
return /* @__PURE__ */
|
2525
|
-
|
1989
|
+
}), Ge = () => T ? Ne(T.network) : [];
|
1990
|
+
return /* @__PURE__ */ a.jsx(a.Fragment, { children: p && /* @__PURE__ */ a.jsx(
|
1991
|
+
Lt,
|
2526
1992
|
{
|
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:
|
1993
|
+
isOpen: p,
|
1994
|
+
onClose: he,
|
1995
|
+
payment: M,
|
1996
|
+
paymentStatus: V,
|
1997
|
+
selectedPaymentMethod: T,
|
1998
|
+
onPaymentMethodSelect: Be,
|
1999
|
+
onPayment: ze,
|
2000
|
+
onBack: We,
|
2001
|
+
error: I,
|
2002
|
+
theme: oe,
|
2003
|
+
merchantName: u,
|
2004
|
+
transactionHash: ee,
|
2005
|
+
walletConnection: O,
|
2006
|
+
onConnectWallet: Qe,
|
2007
|
+
testMode: l,
|
2008
|
+
supportedNetworks: ae,
|
2009
|
+
availableWallets: H,
|
2010
|
+
supportedWallets: Ge(),
|
2011
|
+
step: X
|
2546
2012
|
}
|
2547
2013
|
) });
|
2548
2014
|
});
|
2549
|
-
|
2550
|
-
const
|
2551
|
-
apiUrl: "
|
2015
|
+
Ot.displayName = "CoinleyCheckout";
|
2016
|
+
const qt = {
|
2017
|
+
apiUrl: "http://localhost:9000",
|
2552
2018
|
debug: !1,
|
2553
2019
|
testMode: !1,
|
2554
|
-
theme: "light"
|
2555
|
-
|
2020
|
+
theme: "light",
|
2021
|
+
supportedNetworks: ["ethereum", "bsc", "tron", "algorand"]
|
2022
|
+
}, $t = "0.3.1";
|
2556
2023
|
export {
|
2557
|
-
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2561
|
-
|
2562
|
-
|
2563
|
-
|
2564
|
-
|
2565
|
-
|
2566
|
-
|
2567
|
-
|
2568
|
-
|
2569
|
-
|
2570
|
-
|
2024
|
+
Ot as CoinleyCheckout,
|
2025
|
+
Lt as CoinleyModal,
|
2026
|
+
Gt as CoinleyProvider,
|
2027
|
+
qt as DEFAULT_CONFIG,
|
2028
|
+
de as NETWORK_CONFIG,
|
2029
|
+
A as NETWORK_TYPES,
|
2030
|
+
Rt as PaymentMethods,
|
2031
|
+
le as PaymentStatus,
|
2032
|
+
Vt as QRCode,
|
2033
|
+
Xe as TOKEN_CONFIG,
|
2034
|
+
zt as ThemeProvider,
|
2035
|
+
$t as VERSION,
|
2036
|
+
N as WALLET_TYPES,
|
2037
|
+
et as connectWallet,
|
2038
|
+
ut as createPayment,
|
2039
|
+
ue as detectWallets,
|
2040
|
+
Qt as generateMockTransactionHash,
|
2041
|
+
Bt as getMerchantProfile,
|
2042
|
+
It as getPayment,
|
2043
|
+
Ft as getSupportedNetworks,
|
2044
|
+
Ne as getSupportedWalletsForNetwork,
|
2045
|
+
ct as getWalletInstallUrl,
|
2046
|
+
ht as processPayment,
|
2047
|
+
ot as sendTransaction,
|
2048
|
+
Nt as useCoinley,
|
2049
|
+
Wt as validateWalletAddress
|
2571
2050
|
};
|
2572
2051
|
//# sourceMappingURL=coinley-checkout.es.js.map
|