@nice2dev/ui-money 1.0.11 → 1.0.14
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/components/NiceMoneyInput.d.ts +15 -0
- package/dist/components/NiceTaxBreakdown.d.ts +46 -0
- package/dist/exchange.d.ts +39 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +948 -755
- package/dist/processors.d.ts +23 -0
- package/dist/style.css +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import { jsxs as N, jsx as
|
|
6
|
-
const
|
|
1
|
+
var Xe = Object.defineProperty;
|
|
2
|
+
var Qe = (t, e, n) => e in t ? Xe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var K = (t, e, n) => Qe(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import Ve, { useState as B, useRef as We, useEffect as et, useMemo as k, useCallback as F, forwardRef as de, useId as Ce } from "react";
|
|
5
|
+
import { jsxs as N, jsx as s } from "react/jsx-runtime";
|
|
6
|
+
const fe = [
|
|
7
7
|
// ── Majors ─────────────────────────────────────
|
|
8
8
|
{ code: "USD", numeric: 840, symbol: "$", name: "US Dollar", decimals: 2, symbolFirst: !0 },
|
|
9
9
|
{ code: "EUR", numeric: 978, symbol: "€", name: "Euro", decimals: 2, symbolFirst: !0 },
|
|
@@ -225,186 +225,186 @@ const se = [
|
|
|
225
225
|
{ code: "ETH", numeric: 0, symbol: "Ξ", name: "Ether", decimals: 8, symbolFirst: !0 },
|
|
226
226
|
{ code: "USDC", numeric: 0, symbol: "USDC", name: "USD Coin", decimals: 6 },
|
|
227
227
|
{ code: "USDT", numeric: 0, symbol: "USDT", name: "Tether", decimals: 6 }
|
|
228
|
-
],
|
|
229
|
-
function
|
|
230
|
-
return
|
|
228
|
+
], Oe = new Map(fe.map((t) => [t.code, t]));
|
|
229
|
+
function V(t) {
|
|
230
|
+
return Oe.get(t.toUpperCase());
|
|
231
231
|
}
|
|
232
|
-
function
|
|
233
|
-
|
|
234
|
-
const e =
|
|
235
|
-
e >= 0 ?
|
|
232
|
+
function Et(t) {
|
|
233
|
+
Oe.set(t.code.toUpperCase(), t);
|
|
234
|
+
const e = fe.findIndex((n) => n.code === t.code);
|
|
235
|
+
e >= 0 ? fe[e] = t : fe.push(t);
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
const n =
|
|
239
|
-
return { amount: (
|
|
237
|
+
function W(t, e) {
|
|
238
|
+
const n = V(e), c = (n == null ? void 0 : n.decimals) ?? 2, r = Math.pow(10, c);
|
|
239
|
+
return { amount: (t < 0 ? -1 : 1) * Math.round(Math.abs(t) * r), currency: e.toUpperCase() };
|
|
240
240
|
}
|
|
241
|
-
function
|
|
242
|
-
const e =
|
|
243
|
-
return
|
|
241
|
+
function Ke(t) {
|
|
242
|
+
const e = V(t.currency), n = (e == null ? void 0 : e.decimals) ?? 2;
|
|
243
|
+
return t.amount / Math.pow(10, n);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
246
|
-
return
|
|
245
|
+
function tt(t, e) {
|
|
246
|
+
return t.currency.toUpperCase() === e.currency.toUpperCase();
|
|
247
247
|
}
|
|
248
|
-
function
|
|
249
|
-
if (!
|
|
250
|
-
throw new Error(`Cannot ${n} different currencies: ${
|
|
248
|
+
function $e(t, e, n) {
|
|
249
|
+
if (!tt(t, e))
|
|
250
|
+
throw new Error(`Cannot ${n} different currencies: ${t.currency} vs ${e.currency}`);
|
|
251
251
|
}
|
|
252
|
-
function
|
|
253
|
-
return
|
|
252
|
+
function me(t, e) {
|
|
253
|
+
return $e(t, e, "add"), { amount: t.amount + e.amount, currency: t.currency };
|
|
254
254
|
}
|
|
255
|
-
function
|
|
256
|
-
return
|
|
255
|
+
function nt(t, e) {
|
|
256
|
+
return $e(t, e, "subtract"), { amount: t.amount - e.amount, currency: t.currency };
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function De(t, e) {
|
|
259
259
|
return {
|
|
260
|
-
amount: (
|
|
261
|
-
currency:
|
|
260
|
+
amount: (t.amount * e < 0 ? -1 : 1) * Math.round(Math.abs(t.amount * e)),
|
|
261
|
+
currency: t.currency
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
|
-
function
|
|
265
|
-
return
|
|
264
|
+
function At(t, e) {
|
|
265
|
+
return $e(t, e, "compare"), t.amount - e.amount;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
268
|
-
return
|
|
267
|
+
function Ot(t) {
|
|
268
|
+
return t.amount === 0;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
271
|
-
return
|
|
270
|
+
function Kt(t) {
|
|
271
|
+
return t.amount < 0;
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
return { amount: -
|
|
273
|
+
function Bt(t) {
|
|
274
|
+
return { amount: -t.amount, currency: t.currency };
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
const n =
|
|
276
|
+
function te(t, e = {}) {
|
|
277
|
+
const n = V(t.currency), c = e.decimals ?? (n == null ? void 0 : n.decimals) ?? 2, r = t.amount / Math.pow(10, c);
|
|
278
278
|
try {
|
|
279
279
|
return new Intl.NumberFormat(e.locale, {
|
|
280
280
|
style: "currency",
|
|
281
|
-
currency:
|
|
282
|
-
minimumFractionDigits:
|
|
283
|
-
maximumFractionDigits:
|
|
281
|
+
currency: t.currency,
|
|
282
|
+
minimumFractionDigits: c,
|
|
283
|
+
maximumFractionDigits: c,
|
|
284
284
|
currencyDisplay: e.currencyDisplay ?? "symbol"
|
|
285
|
-
}).format(
|
|
285
|
+
}).format(r);
|
|
286
286
|
} catch {
|
|
287
|
-
const a = (n == null ? void 0 : n.symbol) ??
|
|
287
|
+
const a = (n == null ? void 0 : n.symbol) ?? t.currency, o = r.toFixed(c);
|
|
288
288
|
return n != null && n.symbolFirst ? `${a}${o}` : `${o} ${a}`;
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
function
|
|
292
|
-
if (!
|
|
291
|
+
function rt(t, e) {
|
|
292
|
+
if (!t)
|
|
293
293
|
return null;
|
|
294
|
-
let n =
|
|
294
|
+
let n = t.replace(/[^\d.,\-]/g, "").trim();
|
|
295
295
|
if (!n || n === "-")
|
|
296
296
|
return null;
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
let
|
|
301
|
-
o === -1 ?
|
|
302
|
-
const
|
|
303
|
-
return Number.isFinite(
|
|
297
|
+
const c = n.startsWith("-");
|
|
298
|
+
c && (n = n.slice(1));
|
|
299
|
+
const r = n.lastIndexOf("."), a = n.lastIndexOf(","), o = Math.max(r, a);
|
|
300
|
+
let i, l = "";
|
|
301
|
+
o === -1 ? i = n : (i = n.slice(0, o).replace(/[.,]/g, ""), l = n.slice(o + 1).replace(/[.,]/g, ""));
|
|
302
|
+
const u = `${i}.${l || "0"}`, m = parseFloat(u);
|
|
303
|
+
return Number.isFinite(m) ? W(c ? -m : m, e) : null;
|
|
304
304
|
}
|
|
305
|
-
function
|
|
306
|
-
const e = (
|
|
305
|
+
function Ne(t) {
|
|
306
|
+
const e = (t || "").replace(/\D/g, "");
|
|
307
307
|
return e ? /^4/.test(e) ? "visa" : /^(5[1-5]|2(2[2-9]|[3-6]\d|7[01]|720))/.test(e) ? "mastercard" : /^3[47]/.test(e) ? "amex" : /^(6011|65|64[4-9]|622(12[6-9]|1[3-9]\d|[2-8]\d\d|9[01]\d|92[0-5]))/.test(e) ? "discover" : /^3(0[0-5]|[68])/.test(e) ? "diners" : /^35(2[89]|[3-8])/.test(e) ? "jcb" : /^62/.test(e) ? "unionpay" : /^(50|5[6-9]|6[0-9])/.test(e) ? "maestro" : /^(2200|2201|2202|2203|2204)/.test(e) ? "mir" : /^(4011|4312|4389|4514|4576|5041|5066|5067|509|6277|6362|6363|650|6516|6550)/.test(e) ? "elo" : /^(606282|3841)/.test(e) ? "hipercard" : "unknown" : "unknown";
|
|
308
308
|
}
|
|
309
|
-
function
|
|
310
|
-
const e = (
|
|
309
|
+
function Be(t) {
|
|
310
|
+
const e = (t || "").replace(/\D/g, "");
|
|
311
311
|
if (e.length < 12 || e.length > 19)
|
|
312
312
|
return !1;
|
|
313
|
-
let n = 0,
|
|
314
|
-
for (let
|
|
315
|
-
let a = e.charCodeAt(
|
|
316
|
-
|
|
313
|
+
let n = 0, c = !1;
|
|
314
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
315
|
+
let a = e.charCodeAt(r) - 48;
|
|
316
|
+
c && (a *= 2, a > 9 && (a -= 9)), n += a, c = !c;
|
|
317
317
|
}
|
|
318
318
|
return n % 10 === 0;
|
|
319
319
|
}
|
|
320
|
-
function
|
|
321
|
-
const n = (
|
|
322
|
-
return
|
|
320
|
+
function ct(t, e) {
|
|
321
|
+
const n = (t || "").replace(/\D/g, ""), c = e ?? Ne(n);
|
|
322
|
+
return c === "amex" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 15)].filter(Boolean).join(" ") : c === "diners" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 14)].filter(Boolean).join(" ") : (n.match(/.{1,4}/g) ?? []).join(" ").trim();
|
|
323
323
|
}
|
|
324
|
-
function
|
|
325
|
-
const n = (
|
|
324
|
+
function Tt(t, e) {
|
|
325
|
+
const n = (t || "").replace(/\D/g, "");
|
|
326
326
|
if (n.length < 4)
|
|
327
327
|
return n;
|
|
328
|
-
const
|
|
329
|
-
return a === "amex" ? [
|
|
328
|
+
const c = n.slice(-4), r = "*".repeat(n.length - 4) + c, a = e ?? Ne(n);
|
|
329
|
+
return a === "amex" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 15)].filter(Boolean).join(" ") : a === "diners" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 14)].filter(Boolean).join(" ") : (r.match(/.{1,4}/g) ?? []).join(" ").trim();
|
|
330
330
|
}
|
|
331
|
-
function
|
|
332
|
-
const e = (
|
|
331
|
+
function Te(t) {
|
|
332
|
+
const e = (t || "").replace(/\D/g, "");
|
|
333
333
|
if (e.length < 3)
|
|
334
334
|
return null;
|
|
335
|
-
const n = e.slice(0, 2),
|
|
336
|
-
return !Number.isFinite(
|
|
335
|
+
const n = e.slice(0, 2), c = e.length >= 4 ? e.slice(-2) : e.slice(2, 4), r = parseInt(n, 10);
|
|
336
|
+
return !Number.isFinite(r) || r < 1 || r > 12 ? null : `${n}/${c}`;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
339
|
-
const n =
|
|
338
|
+
function Le(t, e = /* @__PURE__ */ new Date()) {
|
|
339
|
+
const n = Te(t);
|
|
340
340
|
if (!n)
|
|
341
341
|
return !1;
|
|
342
|
-
const [
|
|
342
|
+
const [c, r] = n.split("/"), a = parseInt(c, 10), o = 2e3 + parseInt(r, 10);
|
|
343
343
|
return new Date(o, a, 0, 23, 59, 59, 999).getTime() >= e.getTime();
|
|
344
344
|
}
|
|
345
|
-
function
|
|
346
|
-
return
|
|
345
|
+
function ye(t) {
|
|
346
|
+
return t === "amex" ? 4 : 3;
|
|
347
347
|
}
|
|
348
|
-
function
|
|
349
|
-
var
|
|
350
|
-
const n = {},
|
|
351
|
-
|
|
352
|
-
const a =
|
|
348
|
+
function Ie(t, e = {}) {
|
|
349
|
+
var u;
|
|
350
|
+
const n = {}, c = Ne(t.number), r = Be(t.number);
|
|
351
|
+
r || (n.number = "Invalid card number");
|
|
352
|
+
const a = Le(t.expiry, e.now);
|
|
353
353
|
a || (n.expiry = "Invalid or expired");
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
const l = !e.requireHolder || (((
|
|
354
|
+
const i = (t.cvc || "").replace(/\D/g, "").length === ye(c);
|
|
355
|
+
i || (n.cvc = `CVC must be ${ye(c)} digits`);
|
|
356
|
+
const l = !e.requireHolder || (((u = t.holderName) == null ? void 0 : u.trim().length) ?? 0) >= 2;
|
|
357
357
|
return l || (n.holderName = "Cardholder name required"), {
|
|
358
|
-
brand:
|
|
359
|
-
numberValid:
|
|
358
|
+
brand: c,
|
|
359
|
+
numberValid: r,
|
|
360
360
|
expiryValid: a,
|
|
361
|
-
cvcValid:
|
|
361
|
+
cvcValid: i,
|
|
362
362
|
holderValid: l,
|
|
363
|
-
isValid:
|
|
363
|
+
isValid: r && a && i && l,
|
|
364
364
|
errors: n
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
|
-
class
|
|
367
|
+
class Lt {
|
|
368
368
|
constructor(e) {
|
|
369
|
-
|
|
369
|
+
K(this, "id", "static");
|
|
370
370
|
this.rates = e;
|
|
371
371
|
}
|
|
372
372
|
async getRate(e, n) {
|
|
373
|
-
const
|
|
374
|
-
if (
|
|
375
|
-
return { base:
|
|
376
|
-
const a = this.rates.find((
|
|
373
|
+
const c = e.toUpperCase(), r = n.toUpperCase();
|
|
374
|
+
if (c === r)
|
|
375
|
+
return { base: c, quote: r, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
376
|
+
const a = this.rates.find((u) => u.base === c && u.quote === r);
|
|
377
377
|
if (a)
|
|
378
378
|
return a;
|
|
379
|
-
const o = this.rates.find((
|
|
379
|
+
const o = this.rates.find((u) => u.base === r && u.quote === c);
|
|
380
380
|
if (o)
|
|
381
|
-
return { base:
|
|
382
|
-
const
|
|
383
|
-
if (
|
|
384
|
-
const
|
|
381
|
+
return { base: c, quote: r, rate: 1 / o.rate, asOf: o.asOf };
|
|
382
|
+
const i = this.rates.find((u) => u.base === c && u.quote === "USD") ?? this.rates.find((u) => u.base === "USD" && u.quote === c), l = this.rates.find((u) => u.base === "USD" && u.quote === r) ?? this.rates.find((u) => u.base === r && u.quote === "USD");
|
|
383
|
+
if (i && l) {
|
|
384
|
+
const u = i.base === "USD" ? 1 / i.rate : i.rate, m = l.base === "USD" ? l.rate : 1 / l.rate;
|
|
385
385
|
return {
|
|
386
|
-
base:
|
|
387
|
-
quote:
|
|
388
|
-
rate:
|
|
386
|
+
base: c,
|
|
387
|
+
quote: r,
|
|
388
|
+
rate: u * m,
|
|
389
389
|
asOf: (/* @__PURE__ */ new Date()).toISOString()
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
|
-
throw new Error(`No FX rate for ${
|
|
392
|
+
throw new Error(`No FX rate for ${c}/${r}`);
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
class
|
|
395
|
+
class ge {
|
|
396
396
|
constructor(e = {}) {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
397
|
+
K(this, "cache", /* @__PURE__ */ new Map());
|
|
398
|
+
K(this, "fetchImpl");
|
|
399
|
+
K(this, "ttl");
|
|
400
400
|
this.fetchImpl = e.fetchImpl ?? fetch, this.ttl = e.cacheTtl ?? 6e4;
|
|
401
401
|
}
|
|
402
402
|
cacheKey(e, n) {
|
|
403
403
|
return `${this.id}:${e.toUpperCase()}/${n.toUpperCase()}`;
|
|
404
404
|
}
|
|
405
405
|
getCached(e, n) {
|
|
406
|
-
const
|
|
407
|
-
return
|
|
406
|
+
const c = this.cacheKey(e, n), r = this.cache.get(c);
|
|
407
|
+
return r && r.expires > Date.now() ? r.rate : (r && this.cache.delete(c), null);
|
|
408
408
|
}
|
|
409
409
|
setCached(e) {
|
|
410
410
|
this.cache.set(this.cacheKey(e.base, e.quote), {
|
|
@@ -413,93 +413,141 @@ class he {
|
|
|
413
413
|
});
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
-
class
|
|
416
|
+
class at extends ge {
|
|
417
417
|
constructor(n = {}) {
|
|
418
418
|
super(n);
|
|
419
|
-
|
|
419
|
+
K(this, "id", "frankfurter");
|
|
420
420
|
}
|
|
421
|
-
async getRate(n,
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
-
return { base:
|
|
425
|
-
const o = this.getCached(
|
|
421
|
+
async getRate(n, c) {
|
|
422
|
+
const r = n.toUpperCase(), a = c.toUpperCase();
|
|
423
|
+
if (r === a)
|
|
424
|
+
return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
425
|
+
const o = this.getCached(r, a);
|
|
426
426
|
if (o)
|
|
427
427
|
return o;
|
|
428
|
-
const
|
|
428
|
+
const i = `https://api.frankfurter.app/latest?from=${r}&to=${a}`, l = await this.fetchImpl(i);
|
|
429
429
|
if (!l.ok)
|
|
430
430
|
throw new Error(`Frankfurter HTTP ${l.status}`);
|
|
431
|
-
const
|
|
432
|
-
if (
|
|
433
|
-
throw new Error(`Frankfurter: no rate for ${
|
|
434
|
-
const
|
|
435
|
-
return this.setCached(
|
|
431
|
+
const u = await l.json(), m = u.rates[a];
|
|
432
|
+
if (m == null)
|
|
433
|
+
throw new Error(`Frankfurter: no rate for ${r}/${a}`);
|
|
434
|
+
const b = { base: r, quote: a, rate: m, asOf: u.date };
|
|
435
|
+
return this.setCached(b), b;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
class
|
|
439
|
-
constructor(n,
|
|
440
|
-
super(
|
|
441
|
-
|
|
438
|
+
class it extends ge {
|
|
439
|
+
constructor(n, c = {}) {
|
|
440
|
+
super(c);
|
|
441
|
+
K(this, "id", "openexchangerates");
|
|
442
442
|
this.appId = n;
|
|
443
443
|
}
|
|
444
|
-
async getRate(n,
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
return { base:
|
|
448
|
-
const o = this.getCached(
|
|
444
|
+
async getRate(n, c) {
|
|
445
|
+
const r = n.toUpperCase(), a = c.toUpperCase();
|
|
446
|
+
if (r === a)
|
|
447
|
+
return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
448
|
+
const o = this.getCached(r, a);
|
|
449
449
|
if (o)
|
|
450
450
|
return o;
|
|
451
|
-
const
|
|
451
|
+
const i = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, l = await this.fetchImpl(i);
|
|
452
452
|
if (!l.ok)
|
|
453
453
|
throw new Error(`OpenExchangeRates HTTP ${l.status}`);
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
throw new Error(`OpenExchangeRates: missing rate for ${
|
|
457
|
-
const
|
|
458
|
-
base:
|
|
454
|
+
const u = await l.json(), m = u.rates[r], b = u.rates[a];
|
|
455
|
+
if (m == null || b == null)
|
|
456
|
+
throw new Error(`OpenExchangeRates: missing rate for ${r} or ${a}`);
|
|
457
|
+
const p = {
|
|
458
|
+
base: r,
|
|
459
459
|
quote: a,
|
|
460
|
-
rate:
|
|
461
|
-
asOf: new Date(
|
|
460
|
+
rate: b / m,
|
|
461
|
+
asOf: new Date(u.timestamp * 1e3).toISOString()
|
|
462
462
|
};
|
|
463
|
-
return this.setCached(
|
|
463
|
+
return this.setCached(p), p;
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
class
|
|
466
|
+
class st extends ge {
|
|
467
467
|
constructor(n = {}) {
|
|
468
468
|
super(n);
|
|
469
|
-
|
|
469
|
+
K(this, "id", "exchangerate.host");
|
|
470
470
|
}
|
|
471
|
-
async getRate(n,
|
|
472
|
-
var
|
|
473
|
-
const
|
|
474
|
-
if (
|
|
475
|
-
return { base:
|
|
476
|
-
const o = this.getCached(
|
|
471
|
+
async getRate(n, c) {
|
|
472
|
+
var p;
|
|
473
|
+
const r = n.toUpperCase(), a = c.toUpperCase();
|
|
474
|
+
if (r === a)
|
|
475
|
+
return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
476
|
+
const o = this.getCached(r, a);
|
|
477
477
|
if (o)
|
|
478
478
|
return o;
|
|
479
|
-
const
|
|
479
|
+
const i = `https://api.exchangerate.host/convert?from=${r}&to=${a}`, l = await this.fetchImpl(i);
|
|
480
480
|
if (!l.ok)
|
|
481
481
|
throw new Error(`exchangerate.host HTTP ${l.status}`);
|
|
482
|
-
const
|
|
483
|
-
return this.setCached(
|
|
482
|
+
const u = await l.json(), m = ((p = u.info) == null ? void 0 : p.rate) ?? u.result, b = { base: r, quote: a, rate: m, asOf: u.date };
|
|
483
|
+
return this.setCached(b), b;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
class ot extends ge {
|
|
487
|
+
constructor(n = {}) {
|
|
488
|
+
super(n);
|
|
489
|
+
K(this, "id", "nbp");
|
|
490
|
+
K(this, "table");
|
|
491
|
+
this.table = n.table ?? "A";
|
|
492
|
+
}
|
|
493
|
+
async getRate(n, c) {
|
|
494
|
+
const r = n.toUpperCase(), a = c.toUpperCase();
|
|
495
|
+
if (r === a)
|
|
496
|
+
return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
497
|
+
const o = this.getCached(r, a);
|
|
498
|
+
if (o)
|
|
499
|
+
return o;
|
|
500
|
+
const i = async (b) => {
|
|
501
|
+
var y;
|
|
502
|
+
if (b === "PLN")
|
|
503
|
+
return { rate: 1, date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) };
|
|
504
|
+
const p = `https://api.nbp.pl/api/exchangerates/rates/${this.table}/${b}/?format=json`, d = await this.fetchImpl(p);
|
|
505
|
+
if (!d.ok)
|
|
506
|
+
return null;
|
|
507
|
+
const h = (y = (await d.json()).rates) == null ? void 0 : y[0];
|
|
508
|
+
return h ? { rate: h.mid ?? h.ask ?? 0, date: h.effectiveDate } : null;
|
|
509
|
+
}, l = await i(r), u = await i(a);
|
|
510
|
+
if (!l || !u || l.rate === 0)
|
|
511
|
+
throw new Error(`NBP: missing rate for ${r} or ${a}`);
|
|
512
|
+
const m = {
|
|
513
|
+
base: r,
|
|
514
|
+
quote: a,
|
|
515
|
+
rate: l.rate / u.rate,
|
|
516
|
+
asOf: l.date
|
|
517
|
+
};
|
|
518
|
+
return this.setCached(m), m;
|
|
484
519
|
}
|
|
485
520
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
521
|
+
class lt extends at {
|
|
522
|
+
constructor() {
|
|
523
|
+
super(...arguments);
|
|
524
|
+
K(this, "id", "ecb");
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
class ut extends st {
|
|
528
|
+
constructor() {
|
|
529
|
+
super(...arguments);
|
|
530
|
+
K(this, "id", "free-forex");
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
const qt = (t = {}) => new ot(t), Ht = (t = {}) => new lt(t), jt = (t) => new it(t.apiKey, t), zt = (t = {}) => new ut(t);
|
|
534
|
+
async function dt(t, e, n) {
|
|
535
|
+
const c = e.toUpperCase();
|
|
536
|
+
if (t.currency.toUpperCase() === c)
|
|
537
|
+
return t;
|
|
538
|
+
const r = V(t.currency), a = V(c), o = (r == null ? void 0 : r.decimals) ?? 2, i = (a == null ? void 0 : a.decimals) ?? 2, { rate: l } = await n.getRate(t.currency, c), m = t.amount / Math.pow(10, o) * l;
|
|
491
539
|
return {
|
|
492
|
-
currency:
|
|
493
|
-
amount: Math.round(
|
|
540
|
+
currency: c,
|
|
541
|
+
amount: Math.round(m * Math.pow(10, i))
|
|
494
542
|
};
|
|
495
543
|
}
|
|
496
|
-
class
|
|
544
|
+
class mt {
|
|
497
545
|
constructor(e = {}) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
546
|
+
K(this, "id");
|
|
547
|
+
K(this, "name");
|
|
548
|
+
K(this, "supportedCurrencies");
|
|
549
|
+
K(this, "minimums");
|
|
550
|
+
K(this, "counter", 0);
|
|
503
551
|
this.id = e.id ?? "mock", this.name = e.name ?? "Mock Processor", this.supportedCurrencies = e.supportedCurrencies ?? "*";
|
|
504
552
|
}
|
|
505
553
|
newId(e) {
|
|
@@ -534,28 +582,28 @@ class Ze {
|
|
|
534
582
|
};
|
|
535
583
|
}
|
|
536
584
|
}
|
|
537
|
-
function
|
|
585
|
+
function j(t, e, n, c, r) {
|
|
538
586
|
const a = (o) => {
|
|
539
|
-
const
|
|
540
|
-
return
|
|
587
|
+
const i = c == null ? void 0 : c[o];
|
|
588
|
+
return i || (async () => {
|
|
541
589
|
throw new Error(
|
|
542
590
|
`[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(o)}\` implementation that calls the ${e} SDK.`
|
|
543
591
|
);
|
|
544
592
|
});
|
|
545
593
|
};
|
|
546
594
|
return {
|
|
547
|
-
id:
|
|
595
|
+
id: t,
|
|
548
596
|
name: e,
|
|
549
597
|
supportedCurrencies: n,
|
|
550
|
-
minimums:
|
|
598
|
+
minimums: r,
|
|
551
599
|
authorize: a("authorize"),
|
|
552
600
|
capture: a("capture"),
|
|
553
601
|
cancel: a("cancel"),
|
|
554
602
|
refund: a("refund")
|
|
555
603
|
};
|
|
556
604
|
}
|
|
557
|
-
function
|
|
558
|
-
return
|
|
605
|
+
function pt(t) {
|
|
606
|
+
return j("stripe", "Stripe", "*", t, {
|
|
559
607
|
USD: 50,
|
|
560
608
|
EUR: 50,
|
|
561
609
|
GBP: 30,
|
|
@@ -569,8 +617,8 @@ function Je(r) {
|
|
|
569
617
|
PLN: 200
|
|
570
618
|
});
|
|
571
619
|
}
|
|
572
|
-
function
|
|
573
|
-
return
|
|
620
|
+
function yt(t) {
|
|
621
|
+
return j(
|
|
574
622
|
"paypal",
|
|
575
623
|
"PayPal",
|
|
576
624
|
[
|
|
@@ -597,666 +645,710 @@ function Qe(r) {
|
|
|
597
645
|
"PHP",
|
|
598
646
|
"ILS"
|
|
599
647
|
],
|
|
600
|
-
|
|
648
|
+
t
|
|
601
649
|
);
|
|
602
650
|
}
|
|
603
|
-
function
|
|
604
|
-
return
|
|
651
|
+
function ft(t) {
|
|
652
|
+
return j("adyen", "Adyen", "*", t);
|
|
605
653
|
}
|
|
606
|
-
function
|
|
607
|
-
return
|
|
654
|
+
function ht(t) {
|
|
655
|
+
return j("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], t);
|
|
608
656
|
}
|
|
609
|
-
function
|
|
610
|
-
return
|
|
657
|
+
function bt(t) {
|
|
658
|
+
return j("mollie", "Mollie", "*", t);
|
|
611
659
|
}
|
|
612
|
-
function
|
|
613
|
-
return
|
|
660
|
+
function _t(t) {
|
|
661
|
+
return j("braintree", "Braintree", "*", t);
|
|
614
662
|
}
|
|
615
|
-
function
|
|
616
|
-
return
|
|
663
|
+
function Nt(t) {
|
|
664
|
+
return j("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], t);
|
|
617
665
|
}
|
|
618
|
-
function
|
|
619
|
-
return
|
|
666
|
+
function gt(t) {
|
|
667
|
+
return j(
|
|
620
668
|
"payu",
|
|
621
669
|
"PayU",
|
|
622
670
|
["PLN", "EUR", "USD", "CZK", "HUF", "RON", "BGN", "TRY"],
|
|
623
|
-
|
|
671
|
+
t
|
|
624
672
|
);
|
|
625
673
|
}
|
|
626
|
-
function
|
|
627
|
-
return
|
|
674
|
+
function wt(t) {
|
|
675
|
+
return j("przelewy24", "Przelewy24", ["PLN", "EUR"], t);
|
|
676
|
+
}
|
|
677
|
+
function Dt(t = {}) {
|
|
678
|
+
return j("tpay", "Tpay", ["PLN", "EUR", "USD", "GBP"], t);
|
|
679
|
+
}
|
|
680
|
+
function vt(t = {}) {
|
|
681
|
+
return j("autopay", "Autopay", ["PLN", "EUR", "USD", "GBP", "CZK"], t);
|
|
628
682
|
}
|
|
629
|
-
function
|
|
630
|
-
|
|
683
|
+
function Ct(t = {}) {
|
|
684
|
+
const { acquirer: e = "native", ...n } = t;
|
|
685
|
+
return j(`blik:${e}`, `BLIK (${e})`, ["PLN"], n);
|
|
686
|
+
}
|
|
687
|
+
function $t(t) {
|
|
688
|
+
return j(
|
|
631
689
|
"klarna",
|
|
632
690
|
"Klarna",
|
|
633
691
|
["USD", "EUR", "GBP", "SEK", "NOK", "DKK", "CHF", "AUD", "CAD", "NZD", "PLN"],
|
|
634
|
-
|
|
692
|
+
t
|
|
635
693
|
);
|
|
636
694
|
}
|
|
637
|
-
function
|
|
638
|
-
return
|
|
695
|
+
function xt(t) {
|
|
696
|
+
return j(
|
|
639
697
|
"coinbase-commerce",
|
|
640
698
|
"Coinbase Commerce",
|
|
641
699
|
["BTC", "ETH", "USDC", "USDT", "USD", "EUR"],
|
|
642
|
-
|
|
700
|
+
t
|
|
643
701
|
);
|
|
644
702
|
}
|
|
645
|
-
const
|
|
646
|
-
mock: () => new
|
|
647
|
-
stripe: () =>
|
|
648
|
-
paypal: () =>
|
|
649
|
-
adyen: () =>
|
|
650
|
-
square: () =>
|
|
651
|
-
mollie: () =>
|
|
652
|
-
braintree: () =>
|
|
653
|
-
razorpay: () =>
|
|
654
|
-
payu: () =>
|
|
655
|
-
przelewy24: () =>
|
|
656
|
-
|
|
657
|
-
|
|
703
|
+
const Gt = {
|
|
704
|
+
mock: () => new mt(),
|
|
705
|
+
stripe: () => pt(),
|
|
706
|
+
paypal: () => yt(),
|
|
707
|
+
adyen: () => ft(),
|
|
708
|
+
square: () => ht(),
|
|
709
|
+
mollie: () => bt(),
|
|
710
|
+
braintree: () => _t(),
|
|
711
|
+
razorpay: () => Nt(),
|
|
712
|
+
payu: () => gt(),
|
|
713
|
+
przelewy24: () => wt(),
|
|
714
|
+
tpay: () => Dt(),
|
|
715
|
+
autopay: () => vt(),
|
|
716
|
+
blik: () => Ct(),
|
|
717
|
+
klarna: () => $t(),
|
|
718
|
+
"coinbase-commerce": () => xt()
|
|
658
719
|
};
|
|
659
|
-
function
|
|
660
|
-
const n =
|
|
661
|
-
() => "amount" in
|
|
662
|
-
|
|
663
|
-
|
|
720
|
+
function Yt(t, e) {
|
|
721
|
+
const n = k(
|
|
722
|
+
() => "amount" in t ? t : W(
|
|
723
|
+
t.major,
|
|
724
|
+
t.currency
|
|
664
725
|
),
|
|
665
726
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
666
727
|
[]
|
|
667
|
-
), [
|
|
668
|
-
(
|
|
728
|
+
), [c, r] = B(n), a = F(
|
|
729
|
+
(p) => r((d) => W(p, d.currency)),
|
|
669
730
|
[]
|
|
670
|
-
), o =
|
|
671
|
-
|
|
672
|
-
}, []),
|
|
673
|
-
(
|
|
731
|
+
), o = F((p) => {
|
|
732
|
+
r((d) => ({ ...d, currency: p.toUpperCase() }));
|
|
733
|
+
}, []), i = F((p) => r((d) => me(d, p)), []), l = F(
|
|
734
|
+
(p) => r((d) => nt(d, p)),
|
|
674
735
|
[]
|
|
675
|
-
),
|
|
676
|
-
(
|
|
736
|
+
), u = F(
|
|
737
|
+
(p) => r((d) => De(d, p)),
|
|
677
738
|
[]
|
|
678
|
-
),
|
|
679
|
-
return { money:
|
|
739
|
+
), m = k(() => te(c, { locale: e }), [c, e]), b = k(() => Ke(c), [c]);
|
|
740
|
+
return { money: c, setMoney: r, setMajor: a, setCurrency: o, add: i, subtract: l, scale: u, formatted: m, major: b };
|
|
680
741
|
}
|
|
681
|
-
function
|
|
682
|
-
const [
|
|
683
|
-
return
|
|
684
|
-
if (!
|
|
685
|
-
|
|
742
|
+
function ve(t, e, n) {
|
|
743
|
+
const [c, r] = B(null), [a, o] = B(null), [i, l] = B(!1), u = We(0);
|
|
744
|
+
return et(() => {
|
|
745
|
+
if (!t) {
|
|
746
|
+
r(null);
|
|
686
747
|
return;
|
|
687
748
|
}
|
|
688
|
-
const
|
|
689
|
-
l(!0), o(null),
|
|
690
|
-
|
|
691
|
-
}).catch((
|
|
692
|
-
|
|
749
|
+
const m = ++u.current;
|
|
750
|
+
l(!0), o(null), dt(t, e, n).then((b) => {
|
|
751
|
+
u.current === m && r(b);
|
|
752
|
+
}).catch((b) => {
|
|
753
|
+
u.current === m && (o(b instanceof Error ? b : new Error(String(b))), r(null));
|
|
693
754
|
}).finally(() => {
|
|
694
|
-
|
|
755
|
+
u.current === m && l(!1);
|
|
695
756
|
});
|
|
696
|
-
}, [
|
|
757
|
+
}, [t == null ? void 0 : t.amount, t == null ? void 0 : t.currency, e, n]), { converted: c, loading: i, error: a };
|
|
697
758
|
}
|
|
698
|
-
function
|
|
699
|
-
const [e, n] =
|
|
700
|
-
n("idle"),
|
|
701
|
-
}, []), l =
|
|
702
|
-
async (
|
|
759
|
+
function St(t) {
|
|
760
|
+
const [e, n] = B("idle"), [c, r] = B(null), [a, o] = B(null), i = F(() => {
|
|
761
|
+
n("idle"), r(null), o(null);
|
|
762
|
+
}, []), l = F(
|
|
763
|
+
async (p) => {
|
|
703
764
|
n("authorizing"), o(null);
|
|
704
765
|
try {
|
|
705
|
-
const d = await
|
|
706
|
-
return
|
|
766
|
+
const d = await t.authorize(p);
|
|
767
|
+
return r(d), n(d.status), d;
|
|
707
768
|
} catch (d) {
|
|
708
|
-
const
|
|
709
|
-
throw o(
|
|
769
|
+
const f = d instanceof Error ? d : new Error(String(d));
|
|
770
|
+
throw o(f), n("failed"), f;
|
|
710
771
|
}
|
|
711
772
|
},
|
|
712
|
-
[
|
|
713
|
-
),
|
|
714
|
-
async (
|
|
715
|
-
const
|
|
716
|
-
if (!
|
|
773
|
+
[t]
|
|
774
|
+
), u = F(
|
|
775
|
+
async (p, d) => {
|
|
776
|
+
const f = p ?? (c == null ? void 0 : c.id);
|
|
777
|
+
if (!f)
|
|
717
778
|
throw new Error("No authorization id to capture");
|
|
718
779
|
n("capturing");
|
|
719
780
|
try {
|
|
720
|
-
const
|
|
721
|
-
return
|
|
722
|
-
} catch (
|
|
723
|
-
const
|
|
724
|
-
throw o(
|
|
781
|
+
const h = await t.capture(f, d);
|
|
782
|
+
return r(h), n(h.status), h;
|
|
783
|
+
} catch (h) {
|
|
784
|
+
const y = h instanceof Error ? h : new Error(String(h));
|
|
785
|
+
throw o(y), n("failed"), y;
|
|
725
786
|
}
|
|
726
787
|
},
|
|
727
|
-
[
|
|
728
|
-
),
|
|
729
|
-
async (
|
|
730
|
-
const d =
|
|
788
|
+
[t, c == null ? void 0 : c.id]
|
|
789
|
+
), m = F(
|
|
790
|
+
async (p) => {
|
|
791
|
+
const d = p ?? (c == null ? void 0 : c.id);
|
|
731
792
|
if (!d)
|
|
732
793
|
throw new Error("No payment id to cancel");
|
|
733
|
-
const
|
|
734
|
-
return
|
|
794
|
+
const f = await t.cancel(d);
|
|
795
|
+
return r(f), n(f.status), f;
|
|
735
796
|
},
|
|
736
|
-
[
|
|
737
|
-
),
|
|
738
|
-
async (
|
|
739
|
-
const
|
|
740
|
-
if (!
|
|
797
|
+
[t, c == null ? void 0 : c.id]
|
|
798
|
+
), b = F(
|
|
799
|
+
async (p, d) => {
|
|
800
|
+
const f = p ?? (c == null ? void 0 : c.id);
|
|
801
|
+
if (!f)
|
|
741
802
|
throw new Error("No payment id to refund");
|
|
742
|
-
const
|
|
743
|
-
return
|
|
803
|
+
const h = await t.refund(f, d);
|
|
804
|
+
return r(h), n(h.status), h;
|
|
744
805
|
},
|
|
745
|
-
[
|
|
806
|
+
[t, c == null ? void 0 : c.id]
|
|
746
807
|
);
|
|
747
|
-
return { status: e, response:
|
|
808
|
+
return { status: e, response: c, error: a, authorize: l, capture: u, cancel: m, refund: b, reset: i };
|
|
748
809
|
}
|
|
749
|
-
const
|
|
810
|
+
const Fe = de(function({
|
|
750
811
|
value: e,
|
|
751
812
|
amount: n,
|
|
752
|
-
currency:
|
|
753
|
-
locale:
|
|
813
|
+
currency: c,
|
|
814
|
+
locale: r,
|
|
754
815
|
display: a = "symbol",
|
|
755
816
|
highlightNegative: o = !0,
|
|
756
|
-
zeroPlaceholder:
|
|
817
|
+
zeroPlaceholder: i,
|
|
757
818
|
convertTo: l,
|
|
758
|
-
exchangeProvider:
|
|
759
|
-
className:
|
|
760
|
-
style:
|
|
761
|
-
"aria-label":
|
|
819
|
+
exchangeProvider: u,
|
|
820
|
+
className: m,
|
|
821
|
+
style: b,
|
|
822
|
+
"aria-label": p
|
|
762
823
|
}, d) {
|
|
763
|
-
const
|
|
824
|
+
const f = k(() => {
|
|
764
825
|
if (e)
|
|
765
826
|
return e;
|
|
766
|
-
if (n != null &&
|
|
767
|
-
const
|
|
827
|
+
if (n != null && c) {
|
|
828
|
+
const g = V(c), v = (g == null ? void 0 : g.decimals) ?? 2;
|
|
768
829
|
return {
|
|
769
|
-
amount: Math.round(n * Math.pow(10,
|
|
770
|
-
currency:
|
|
830
|
+
amount: Math.round(n * Math.pow(10, v)),
|
|
831
|
+
currency: c.toUpperCase()
|
|
771
832
|
};
|
|
772
833
|
}
|
|
773
834
|
return null;
|
|
774
|
-
}, [e, n,
|
|
775
|
-
l &&
|
|
835
|
+
}, [e, n, c]), h = k(() => f ? f.amount === 0 && i != null ? i : te(f, { locale: r, currencyDisplay: a }) : "", [f, r, a, i]), { converted: y } = ve(
|
|
836
|
+
l && u ? f : null,
|
|
776
837
|
l ?? "",
|
|
777
|
-
|
|
838
|
+
u
|
|
778
839
|
);
|
|
779
|
-
if (!
|
|
840
|
+
if (!f)
|
|
780
841
|
return null;
|
|
781
|
-
const
|
|
782
|
-
return /* @__PURE__ */ N("span", { ref: d, className:
|
|
783
|
-
/* @__PURE__ */
|
|
784
|
-
|
|
842
|
+
const _ = f.amount < 0, S = "nice-money" + (o && _ ? " nice-money--negative" : "") + (m ? ` ${m}` : "");
|
|
843
|
+
return /* @__PURE__ */ N("span", { ref: d, className: S, style: b, "aria-label": p, children: [
|
|
844
|
+
/* @__PURE__ */ s("span", { className: "nice-money__value", children: h }),
|
|
845
|
+
y && /* @__PURE__ */ N("span", { className: "nice-money__converted", "aria-label": `Converted to ${y.currency}`, children: [
|
|
785
846
|
" ≈ ",
|
|
786
|
-
|
|
847
|
+
te(y, { locale: r })
|
|
787
848
|
] })
|
|
788
849
|
] });
|
|
789
|
-
}),
|
|
850
|
+
}), Zt = fe.map((t) => t.code).sort(), qe = de(
|
|
790
851
|
function({
|
|
791
852
|
value: e,
|
|
792
853
|
onChange: n,
|
|
793
|
-
options:
|
|
794
|
-
recents:
|
|
854
|
+
options: c = fe,
|
|
855
|
+
recents: r = [],
|
|
795
856
|
searchable: a,
|
|
796
857
|
showCode: o = !0,
|
|
797
|
-
showSymbol:
|
|
858
|
+
showSymbol: i = !0,
|
|
798
859
|
compact: l = !1,
|
|
799
|
-
disabled:
|
|
800
|
-
readOnly:
|
|
801
|
-
loading:
|
|
802
|
-
accessMode:
|
|
860
|
+
disabled: u,
|
|
861
|
+
readOnly: m,
|
|
862
|
+
loading: b,
|
|
863
|
+
accessMode: p,
|
|
803
864
|
label: d,
|
|
804
|
-
helperText:
|
|
805
|
-
error:
|
|
806
|
-
required:
|
|
807
|
-
size:
|
|
808
|
-
labelPlacement:
|
|
809
|
-
labelWidth:
|
|
810
|
-
controlWidth:
|
|
811
|
-
className:
|
|
812
|
-
style:
|
|
813
|
-
id:
|
|
814
|
-
name:
|
|
815
|
-
title:
|
|
816
|
-
"data-testid":
|
|
817
|
-
"aria-label":
|
|
818
|
-
placeholder:
|
|
819
|
-
},
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
return t.filter(
|
|
827
|
-
(S) => S.code.toLowerCase().includes(p) || S.name.toLowerCase().includes(p) || S.symbol.toLowerCase().includes(p)
|
|
865
|
+
helperText: f,
|
|
866
|
+
error: h,
|
|
867
|
+
required: y,
|
|
868
|
+
size: _ = "md",
|
|
869
|
+
labelPlacement: S = "top",
|
|
870
|
+
labelWidth: g,
|
|
871
|
+
controlWidth: v,
|
|
872
|
+
className: O,
|
|
873
|
+
style: Y,
|
|
874
|
+
id: Z,
|
|
875
|
+
name: R,
|
|
876
|
+
title: q,
|
|
877
|
+
"data-testid": ne,
|
|
878
|
+
"aria-label": E,
|
|
879
|
+
placeholder: J
|
|
880
|
+
}, z) {
|
|
881
|
+
const P = p === "hidden", X = u || p === "disabled" || b, se = m || p === "readOnly", A = Ce(), oe = Z ?? `nice-cs-${A}`, [H, U] = B(""), M = a ?? c.length > 8, T = k(() => {
|
|
882
|
+
if (!H.trim())
|
|
883
|
+
return c;
|
|
884
|
+
const D = H.trim().toLowerCase();
|
|
885
|
+
return c.filter(
|
|
886
|
+
(C) => C.code.toLowerCase().includes(D) || C.name.toLowerCase().includes(D) || C.symbol.toLowerCase().includes(D)
|
|
828
887
|
);
|
|
829
|
-
}, [
|
|
830
|
-
const
|
|
831
|
-
return
|
|
832
|
-
}, [
|
|
833
|
-
(
|
|
834
|
-
const
|
|
835
|
-
|
|
888
|
+
}, [c, H]), x = k(() => {
|
|
889
|
+
const D = /* @__PURE__ */ new Set();
|
|
890
|
+
return r.map((C) => V(C)).filter((C) => !!C && !D.has(C.code) && !!D.add(C.code));
|
|
891
|
+
}, [r]), le = F(
|
|
892
|
+
(D) => {
|
|
893
|
+
const C = D.target.value, ce = V(C);
|
|
894
|
+
ce && (n == null || n(C, ce));
|
|
836
895
|
},
|
|
837
896
|
[n]
|
|
838
|
-
),
|
|
897
|
+
), ee = (D) => {
|
|
839
898
|
if (l)
|
|
840
|
-
return `${
|
|
841
|
-
const
|
|
842
|
-
return
|
|
843
|
-
},
|
|
844
|
-
width: typeof
|
|
899
|
+
return `${i ? D.symbol + " " : ""}${D.code}`;
|
|
900
|
+
const C = [];
|
|
901
|
+
return i && C.push(D.symbol), o && C.push(D.code), C.push("—", D.name), C.join(" ");
|
|
902
|
+
}, w = `nice-currency-selector nice-currency-selector--${_} nice-currency-selector--label-${S}` + (l ? " nice-currency-selector--compact" : "") + (h ? " nice-currency-selector--error" : "") + (X ? " nice-currency-selector--disabled" : "") + (O ? ` ${O}` : ""), I = S === "left" && g != null ? { width: typeof g == "number" ? `${g}px` : g, flex: "none" } : void 0, re = v != null ? {
|
|
903
|
+
width: typeof v == "number" ? `${v}px` : v,
|
|
845
904
|
flex: "none"
|
|
846
905
|
} : void 0;
|
|
847
|
-
return /* @__PURE__ */ N("div", { ref:
|
|
848
|
-
d && /* @__PURE__ */ N("label", { htmlFor:
|
|
906
|
+
return P ? null : /* @__PURE__ */ N("div", { ref: z, className: w, style: Y, title: q, "data-testid": ne, children: [
|
|
907
|
+
d && /* @__PURE__ */ N("label", { htmlFor: oe, className: "nice-currency-selector__label", style: I, children: [
|
|
849
908
|
d,
|
|
850
|
-
|
|
909
|
+
y && /* @__PURE__ */ s("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
|
|
851
910
|
] }),
|
|
852
|
-
/* @__PURE__ */ N("div", { className: "nice-currency-selector__inner", style:
|
|
853
|
-
|
|
911
|
+
/* @__PURE__ */ N("div", { className: "nice-currency-selector__inner", style: re, children: [
|
|
912
|
+
M && /* @__PURE__ */ s(
|
|
854
913
|
"input",
|
|
855
914
|
{
|
|
856
915
|
type: "search",
|
|
857
916
|
className: "nice-currency-selector__search",
|
|
858
917
|
placeholder: "Search currency…",
|
|
859
|
-
value:
|
|
860
|
-
onChange: (
|
|
861
|
-
disabled:
|
|
918
|
+
value: H,
|
|
919
|
+
onChange: (D) => U(D.target.value),
|
|
920
|
+
disabled: X || se,
|
|
862
921
|
"aria-label": "Search currency"
|
|
863
922
|
}
|
|
864
923
|
),
|
|
865
924
|
/* @__PURE__ */ N(
|
|
866
925
|
"select",
|
|
867
926
|
{
|
|
868
|
-
id:
|
|
869
|
-
name:
|
|
927
|
+
id: oe,
|
|
928
|
+
name: R,
|
|
870
929
|
className: "nice-currency-selector__select",
|
|
871
930
|
value: e ?? "",
|
|
872
|
-
onChange:
|
|
873
|
-
disabled:
|
|
874
|
-
required:
|
|
875
|
-
"aria-invalid": !!
|
|
876
|
-
"aria-label":
|
|
931
|
+
onChange: le,
|
|
932
|
+
disabled: X || se,
|
|
933
|
+
required: y,
|
|
934
|
+
"aria-invalid": !!h,
|
|
935
|
+
"aria-label": E ?? (typeof d == "string" ? d : "Currency"),
|
|
877
936
|
children: [
|
|
878
|
-
!e && /* @__PURE__ */
|
|
879
|
-
|
|
880
|
-
/* @__PURE__ */
|
|
937
|
+
!e && /* @__PURE__ */ s("option", { value: "", children: J ?? "Select currency…" }),
|
|
938
|
+
x.length > 0 && /* @__PURE__ */ s("optgroup", { label: "Recent", children: x.map((D) => /* @__PURE__ */ s("option", { value: D.code, children: ee(D) }, `r-${D.code}`)) }),
|
|
939
|
+
/* @__PURE__ */ s("optgroup", { label: x.length > 0 ? "All" : "", children: T.map((D) => /* @__PURE__ */ s("option", { value: D.code, children: ee(D) }, D.code)) })
|
|
881
940
|
]
|
|
882
941
|
}
|
|
883
942
|
)
|
|
884
943
|
] }),
|
|
885
|
-
(
|
|
944
|
+
(h || f) && /* @__PURE__ */ s(
|
|
886
945
|
"span",
|
|
887
946
|
{
|
|
888
|
-
className:
|
|
889
|
-
children:
|
|
947
|
+
className: h ? "nice-currency-selector__error" : "nice-currency-selector__helper",
|
|
948
|
+
children: h ?? f
|
|
890
949
|
}
|
|
891
950
|
)
|
|
892
951
|
] });
|
|
893
952
|
}
|
|
894
|
-
),
|
|
953
|
+
), He = de(
|
|
895
954
|
function({
|
|
896
955
|
value: e,
|
|
897
956
|
onChange: n,
|
|
898
|
-
currency:
|
|
899
|
-
onCurrencyChange:
|
|
957
|
+
currency: c,
|
|
958
|
+
onCurrencyChange: r,
|
|
900
959
|
currencies: a,
|
|
901
960
|
hideCurrencySelector: o,
|
|
902
|
-
min:
|
|
961
|
+
min: i,
|
|
903
962
|
max: l,
|
|
904
|
-
step:
|
|
905
|
-
locale:
|
|
906
|
-
placeholder:
|
|
907
|
-
label:
|
|
963
|
+
step: u,
|
|
964
|
+
locale: m,
|
|
965
|
+
placeholder: b,
|
|
966
|
+
label: p,
|
|
908
967
|
helperText: d,
|
|
909
|
-
error:
|
|
910
|
-
size:
|
|
911
|
-
disabled:
|
|
912
|
-
readOnly:
|
|
913
|
-
required:
|
|
914
|
-
loading:
|
|
915
|
-
accessMode:
|
|
916
|
-
labelPlacement:
|
|
917
|
-
errorPlacement:
|
|
918
|
-
labelWidth:
|
|
919
|
-
controlWidth:
|
|
920
|
-
submitOnEnter:
|
|
921
|
-
onSubmit:
|
|
922
|
-
showFormattedPreview:
|
|
923
|
-
showSteppers:
|
|
924
|
-
className:
|
|
925
|
-
style:
|
|
926
|
-
id:
|
|
927
|
-
name:
|
|
928
|
-
title:
|
|
929
|
-
"data-testid":
|
|
930
|
-
onBlur:
|
|
931
|
-
onFocus:
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
const
|
|
937
|
-
() => e ? (e.amount / Math.pow(10,
|
|
938
|
-
), [
|
|
939
|
-
|
|
940
|
-
if (
|
|
968
|
+
error: f,
|
|
969
|
+
size: h = "md",
|
|
970
|
+
disabled: y,
|
|
971
|
+
readOnly: _,
|
|
972
|
+
required: S,
|
|
973
|
+
loading: g,
|
|
974
|
+
accessMode: v,
|
|
975
|
+
labelPlacement: O = "top",
|
|
976
|
+
errorPlacement: Y = "bottom",
|
|
977
|
+
labelWidth: Z,
|
|
978
|
+
controlWidth: R,
|
|
979
|
+
submitOnEnter: q,
|
|
980
|
+
onSubmit: ne,
|
|
981
|
+
showFormattedPreview: E = !0,
|
|
982
|
+
showSteppers: J = !1,
|
|
983
|
+
className: z,
|
|
984
|
+
style: P,
|
|
985
|
+
id: X,
|
|
986
|
+
name: se,
|
|
987
|
+
title: A,
|
|
988
|
+
"data-testid": oe,
|
|
989
|
+
onBlur: H,
|
|
990
|
+
onFocus: U,
|
|
991
|
+
liveGrouping: M,
|
|
992
|
+
multiplierShortcuts: T = !0,
|
|
993
|
+
onValidationError: x
|
|
994
|
+
}, le) {
|
|
995
|
+
const ee = y || v === "disabled" || g, w = _ || v === "readOnly", I = v === "hidden", re = Ce(), D = X ?? `nice-money-${re}`, C = ((e == null ? void 0 : e.currency) ?? c ?? "USD").toUpperCase(), ce = V(C), G = (ce == null ? void 0 : ce.decimals) ?? 2, xe = u ?? 1 / Math.pow(10, G), [we, he] = B(
|
|
996
|
+
() => e ? (e.amount / Math.pow(10, G)).toFixed(G) : ""
|
|
997
|
+
), [be, Se] = B(!1);
|
|
998
|
+
Ve.useEffect(() => {
|
|
999
|
+
if (be)
|
|
941
1000
|
return;
|
|
942
1001
|
if (e == null) {
|
|
943
|
-
|
|
1002
|
+
he("");
|
|
944
1003
|
return;
|
|
945
1004
|
}
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
}, [e,
|
|
949
|
-
const
|
|
950
|
-
(
|
|
951
|
-
|
|
952
|
-
if (
|
|
1005
|
+
const $ = V(e.currency), L = ($ == null ? void 0 : $.decimals) ?? 2;
|
|
1006
|
+
he((e.amount / Math.pow(10, L)).toFixed(L));
|
|
1007
|
+
}, [e, be]);
|
|
1008
|
+
const Ue = F(
|
|
1009
|
+
($) => {
|
|
1010
|
+
let L = $;
|
|
1011
|
+
if (T) {
|
|
1012
|
+
const ie = $.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);
|
|
1013
|
+
if (ie) {
|
|
1014
|
+
const ue = ie[2].toLowerCase() === "k" ? 1e3 : ie[2].toLowerCase() === "m" ? 1e6 : 1e9, ke = Number(ie[1].replace(",", ".")) * ue;
|
|
1015
|
+
if (!Number.isFinite(ke)) {
|
|
1016
|
+
x == null || x(new Error("overflow"));
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
L = String(ke);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
const Q = rt(L, C);
|
|
1023
|
+
if (!Q) {
|
|
953
1024
|
n == null || n(null);
|
|
954
1025
|
return;
|
|
955
1026
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
1027
|
+
if (!Number.isSafeInteger(Q.amount)) {
|
|
1028
|
+
x == null || x(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
const ae = Q.amount / Math.pow(10, G);
|
|
1032
|
+
if (i != null && ae < i) {
|
|
1033
|
+
x == null || x(new Error(`min: ${i}`)), n == null || n(W(i, C));
|
|
959
1034
|
return;
|
|
960
1035
|
}
|
|
961
|
-
if (l != null &&
|
|
962
|
-
n == null || n(
|
|
1036
|
+
if (l != null && ae > l) {
|
|
1037
|
+
x == null || x(new Error(`max: ${l}`)), n == null || n(W(l, C));
|
|
963
1038
|
return;
|
|
964
1039
|
}
|
|
965
|
-
n == null || n(
|
|
1040
|
+
n == null || n(Q);
|
|
966
1041
|
},
|
|
967
|
-
[
|
|
968
|
-
),
|
|
969
|
-
(
|
|
970
|
-
const
|
|
971
|
-
|
|
1042
|
+
[C, G, i, l, n, T, x]
|
|
1043
|
+
), je = F(
|
|
1044
|
+
($) => {
|
|
1045
|
+
const L = $.target.value;
|
|
1046
|
+
he(L), Ue(L);
|
|
972
1047
|
},
|
|
973
|
-
[
|
|
974
|
-
),
|
|
975
|
-
(
|
|
976
|
-
const
|
|
977
|
-
n == null || n(
|
|
1048
|
+
[Ue]
|
|
1049
|
+
), Re = F(
|
|
1050
|
+
($) => {
|
|
1051
|
+
const Q = (e ? e.amount / Math.pow(10, G) : 0) + $, ae = Math.min(l ?? 1 / 0, Math.max(i ?? -1 / 0, Q));
|
|
1052
|
+
n == null || n(W(ae, C));
|
|
978
1053
|
},
|
|
979
|
-
[e,
|
|
980
|
-
),
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1054
|
+
[e, G, i, l, C, n]
|
|
1055
|
+
), _e = k(() => {
|
|
1056
|
+
var $, L;
|
|
1057
|
+
try {
|
|
1058
|
+
const Q = new Intl.NumberFormat(m).formatToParts(12345.6), ae = (($ = Q.find((ue) => ue.type === "group")) == null ? void 0 : $.value) ?? ",", ie = ((L = Q.find((ue) => ue.type === "decimal")) == null ? void 0 : L.value) ?? ".";
|
|
1059
|
+
return { group: ae, decimal: ie };
|
|
1060
|
+
} catch {
|
|
1061
|
+
return { group: ",", decimal: "." };
|
|
1062
|
+
}
|
|
1063
|
+
}, [m]), Me = M ?? !!_e.group, ze = k(() => {
|
|
1064
|
+
if (!Me || be === !1)
|
|
1065
|
+
return we;
|
|
1066
|
+
const $ = _e.decimal, L = _e.group, Q = we.replace(
|
|
1067
|
+
new RegExp(`[${L.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`, "g"),
|
|
1068
|
+
""
|
|
1069
|
+
), [ae, ie] = Q.split($);
|
|
1070
|
+
if (!ae)
|
|
1071
|
+
return Q;
|
|
1072
|
+
const ue = ae.replace(/\B(?=(\d{3})+(?!\d))/g, L);
|
|
1073
|
+
return ie != null ? `${ue}${$}${ie}` : ue;
|
|
1074
|
+
}, [we, be, Me, _e]), Pe = k(() => e ? te(e, { locale: m }) : "", [e, m]), pe = typeof f == "string" ? f : void 0, Ge = `nice-money-input nice-money-input--${h} nice-money-input--label-${O} nice-money-input--error-${Y}` + (pe ? " nice-money-input--error" : "") + (ee ? " nice-money-input--disabled" : "") + (g ? " nice-money-input--loading" : "") + (z ? ` ${z}` : ""), Ye = ($) => {
|
|
1075
|
+
q && $.key === "Enter" && ne && ($.preventDefault(), ne());
|
|
1076
|
+
}, Ze = O === "left" && Z != null ? { width: typeof Z == "number" ? `${Z}px` : Z, flex: "none" } : void 0, Je = R != null ? {
|
|
1077
|
+
width: typeof R == "number" ? `${R}px` : R,
|
|
984
1078
|
flex: "none"
|
|
985
1079
|
} : void 0;
|
|
986
|
-
return /* @__PURE__ */ N("div", { ref:
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1080
|
+
return I ? null : /* @__PURE__ */ N("div", { ref: le, className: Ge, style: P, title: A, "data-testid": oe, children: [
|
|
1081
|
+
p && /* @__PURE__ */ N("label", { htmlFor: D, className: "nice-money-input__label", style: Ze, children: [
|
|
1082
|
+
p,
|
|
1083
|
+
S && /* @__PURE__ */ s("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
|
|
990
1084
|
] }),
|
|
991
|
-
/* @__PURE__ */ N("div", { className: "nice-money-input__row", style:
|
|
992
|
-
!o && /* @__PURE__ */
|
|
993
|
-
|
|
1085
|
+
/* @__PURE__ */ N("div", { className: "nice-money-input__row", style: Je, children: [
|
|
1086
|
+
!o && /* @__PURE__ */ s(
|
|
1087
|
+
qe,
|
|
994
1088
|
{
|
|
995
|
-
value:
|
|
1089
|
+
value: C,
|
|
996
1090
|
compact: !0,
|
|
997
|
-
options: a ? a.map(
|
|
998
|
-
onChange: (
|
|
999
|
-
disabled:
|
|
1091
|
+
options: a ? a.map(V).filter(($) => !!$) : void 0,
|
|
1092
|
+
onChange: ($) => r == null ? void 0 : r($),
|
|
1093
|
+
disabled: ee || w,
|
|
1000
1094
|
className: "nice-money-input__currency",
|
|
1001
1095
|
"aria-label": "Currency"
|
|
1002
1096
|
}
|
|
1003
1097
|
),
|
|
1004
|
-
o && /* @__PURE__ */
|
|
1005
|
-
|
|
1098
|
+
o && /* @__PURE__ */ s("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (ce == null ? void 0 : ce.symbol) ?? C }),
|
|
1099
|
+
J && /* @__PURE__ */ s(
|
|
1006
1100
|
"button",
|
|
1007
1101
|
{
|
|
1008
1102
|
type: "button",
|
|
1009
1103
|
className: "nice-money-input__step nice-money-input__step--down",
|
|
1010
|
-
onClick: () =>
|
|
1011
|
-
disabled:
|
|
1104
|
+
onClick: () => Re(-xe),
|
|
1105
|
+
disabled: ee || w || i != null && e != null && e.amount / Math.pow(10, G) <= i,
|
|
1012
1106
|
"aria-label": "Decrease amount",
|
|
1013
1107
|
tabIndex: -1,
|
|
1014
1108
|
children: "−"
|
|
1015
1109
|
}
|
|
1016
1110
|
),
|
|
1017
|
-
/* @__PURE__ */
|
|
1111
|
+
/* @__PURE__ */ s(
|
|
1018
1112
|
"input",
|
|
1019
1113
|
{
|
|
1020
|
-
id:
|
|
1021
|
-
name:
|
|
1114
|
+
id: D,
|
|
1115
|
+
name: se,
|
|
1022
1116
|
type: "text",
|
|
1023
1117
|
inputMode: "decimal",
|
|
1024
1118
|
autoComplete: "transaction-amount",
|
|
1025
1119
|
className: "nice-money-input__amount",
|
|
1026
|
-
value:
|
|
1027
|
-
onChange:
|
|
1028
|
-
onKeyDown:
|
|
1029
|
-
onFocus: (
|
|
1030
|
-
|
|
1120
|
+
value: ze,
|
|
1121
|
+
onChange: je,
|
|
1122
|
+
onKeyDown: Ye,
|
|
1123
|
+
onFocus: ($) => {
|
|
1124
|
+
Se(!0), U == null || U($);
|
|
1031
1125
|
},
|
|
1032
|
-
onBlur: (
|
|
1033
|
-
|
|
1126
|
+
onBlur: ($) => {
|
|
1127
|
+
Se(!1), e && he((e.amount / Math.pow(10, G)).toFixed(G)), H == null || H($);
|
|
1034
1128
|
},
|
|
1035
|
-
placeholder:
|
|
1036
|
-
disabled:
|
|
1037
|
-
readOnly:
|
|
1038
|
-
required:
|
|
1039
|
-
"aria-invalid": !!
|
|
1040
|
-
"aria-describedby":
|
|
1129
|
+
placeholder: b ?? `0${G > 0 ? "." + "0".repeat(G) : ""}`,
|
|
1130
|
+
disabled: ee,
|
|
1131
|
+
readOnly: w,
|
|
1132
|
+
required: S,
|
|
1133
|
+
"aria-invalid": !!pe,
|
|
1134
|
+
"aria-describedby": pe || d ? `${D}-help` : void 0
|
|
1041
1135
|
}
|
|
1042
1136
|
),
|
|
1043
|
-
|
|
1137
|
+
J && /* @__PURE__ */ s(
|
|
1044
1138
|
"button",
|
|
1045
1139
|
{
|
|
1046
1140
|
type: "button",
|
|
1047
1141
|
className: "nice-money-input__step nice-money-input__step--up",
|
|
1048
|
-
onClick: () =>
|
|
1049
|
-
disabled:
|
|
1142
|
+
onClick: () => Re(xe),
|
|
1143
|
+
disabled: ee || w || l != null && e != null && e.amount / Math.pow(10, G) >= l,
|
|
1050
1144
|
"aria-label": "Increase amount",
|
|
1051
1145
|
tabIndex: -1,
|
|
1052
1146
|
children: "+"
|
|
1053
1147
|
}
|
|
1054
1148
|
),
|
|
1055
|
-
|
|
1149
|
+
g && /* @__PURE__ */ s("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: "⟳" })
|
|
1056
1150
|
] }),
|
|
1057
|
-
|
|
1058
|
-
(
|
|
1151
|
+
E && Pe && /* @__PURE__ */ s("span", { className: "nice-money-input__preview", "aria-live": "polite", children: Pe }),
|
|
1152
|
+
(pe || d) && /* @__PURE__ */ s(
|
|
1059
1153
|
"span",
|
|
1060
1154
|
{
|
|
1061
|
-
id: `${
|
|
1062
|
-
className:
|
|
1063
|
-
children:
|
|
1155
|
+
id: `${D}-help`,
|
|
1156
|
+
className: pe ? "nice-money-input__error" : "nice-money-input__helper",
|
|
1157
|
+
children: pe ?? d
|
|
1064
1158
|
}
|
|
1065
1159
|
)
|
|
1066
1160
|
] });
|
|
1067
1161
|
}
|
|
1068
|
-
),
|
|
1162
|
+
), Ut = { number: "", expiry: "", cvc: "" }, Rt = de(
|
|
1069
1163
|
function({
|
|
1070
|
-
value: e =
|
|
1164
|
+
value: e = Ut,
|
|
1071
1165
|
onChange: n,
|
|
1072
|
-
showHolderName:
|
|
1073
|
-
requireHolderName:
|
|
1166
|
+
showHolderName: c = !0,
|
|
1167
|
+
requireHolderName: r,
|
|
1074
1168
|
showPostalCode: a = !1,
|
|
1075
1169
|
acceptedBrands: o,
|
|
1076
|
-
showBrandIcon:
|
|
1170
|
+
showBrandIcon: i = !0,
|
|
1077
1171
|
size: l = "md",
|
|
1078
|
-
disabled:
|
|
1079
|
-
readOnly:
|
|
1080
|
-
loading:
|
|
1081
|
-
accessMode:
|
|
1172
|
+
disabled: u,
|
|
1173
|
+
readOnly: m,
|
|
1174
|
+
loading: b,
|
|
1175
|
+
accessMode: p,
|
|
1082
1176
|
label: d,
|
|
1083
|
-
helperText:
|
|
1084
|
-
error:
|
|
1085
|
-
required:
|
|
1086
|
-
className:
|
|
1087
|
-
style:
|
|
1088
|
-
id:
|
|
1089
|
-
title:
|
|
1090
|
-
"data-testid":
|
|
1091
|
-
},
|
|
1092
|
-
|
|
1093
|
-
return null;
|
|
1094
|
-
const A = s || m === "disabled" || h, M = y || m === "readOnly", ne = ye(), x = I ?? `nice-cc-${ne}`, [V, O] = E({
|
|
1177
|
+
helperText: f,
|
|
1178
|
+
error: h,
|
|
1179
|
+
required: y,
|
|
1180
|
+
className: _,
|
|
1181
|
+
style: S,
|
|
1182
|
+
id: g,
|
|
1183
|
+
title: v,
|
|
1184
|
+
"data-testid": O
|
|
1185
|
+
}, Y) {
|
|
1186
|
+
const Z = p === "hidden", R = u || p === "disabled" || b, q = m || p === "readOnly", ne = Ce(), E = g ?? `nice-cc-${ne}`, [J, z] = B({
|
|
1095
1187
|
number: !1,
|
|
1096
1188
|
expiry: !1,
|
|
1097
1189
|
cvc: !1,
|
|
1098
1190
|
holder: !1,
|
|
1099
1191
|
postal: !1
|
|
1100
|
-
}),
|
|
1101
|
-
() =>
|
|
1102
|
-
[e,
|
|
1103
|
-
),
|
|
1104
|
-
(
|
|
1105
|
-
const
|
|
1106
|
-
n == null || n(
|
|
1192
|
+
}), P = k(() => Ne(e.number), [e.number]), X = k(
|
|
1193
|
+
() => Ie(e, { requireHolder: r ?? c }),
|
|
1194
|
+
[e, r, c]
|
|
1195
|
+
), se = !o || o.includes(P) || P === "unknown", A = F(
|
|
1196
|
+
(w) => {
|
|
1197
|
+
const I = { ...e, ...w }, re = Ie(I, { requireHolder: r ?? c });
|
|
1198
|
+
n == null || n(I, re);
|
|
1107
1199
|
},
|
|
1108
|
-
[e,
|
|
1109
|
-
),
|
|
1110
|
-
(
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1200
|
+
[e, r, c, n]
|
|
1201
|
+
), oe = F(
|
|
1202
|
+
(w) => {
|
|
1203
|
+
const I = w.target.value.replace(/\D/g, "").slice(0, 19);
|
|
1204
|
+
A({ number: I });
|
|
1113
1205
|
},
|
|
1114
|
-
[
|
|
1115
|
-
),
|
|
1116
|
-
(
|
|
1117
|
-
const
|
|
1118
|
-
let
|
|
1119
|
-
|
|
1206
|
+
[A]
|
|
1207
|
+
), H = F(
|
|
1208
|
+
(w) => {
|
|
1209
|
+
const I = w.target.value.replace(/\D/g, "").slice(0, 4);
|
|
1210
|
+
let re = I;
|
|
1211
|
+
I.length >= 3 ? re = `${I.slice(0, 2)}/${I.slice(2)}` : I.length === 2 && (re = `${I}/`), A({ expiry: re });
|
|
1120
1212
|
},
|
|
1121
|
-
[
|
|
1122
|
-
),
|
|
1123
|
-
(
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1213
|
+
[A]
|
|
1214
|
+
), U = F(
|
|
1215
|
+
(w) => {
|
|
1216
|
+
const I = w.target.value.replace(/\D/g, "").slice(0, ye(P));
|
|
1217
|
+
A({ cvc: I });
|
|
1126
1218
|
},
|
|
1127
|
-
[
|
|
1128
|
-
),
|
|
1129
|
-
return /* @__PURE__ */ N("div", { ref:
|
|
1219
|
+
[P, A]
|
|
1220
|
+
), M = k(() => ct(e.number, P), [e.number, P]), T = J.number && e.number.length > 0 && (Be(e.number) ? se ? void 0 : "Card brand not accepted" : X.errors.number), x = J.expiry && e.expiry.length > 0 && !Le(e.expiry) ? X.errors.expiry : void 0, le = J.cvc && e.cvc.length > 0 && e.cvc.length !== ye(P) ? X.errors.cvc : void 0, ee = `nice-credit-card nice-credit-card--${l}` + (R ? " nice-credit-card--disabled" : "") + (b ? " nice-credit-card--loading" : "") + (h ? " nice-credit-card--error" : "") + (_ ? ` ${_}` : "");
|
|
1221
|
+
return Z ? null : /* @__PURE__ */ N("div", { ref: Y, className: ee, style: S, title: v, "data-testid": O, children: [
|
|
1130
1222
|
d && /* @__PURE__ */ N("div", { className: "nice-credit-card__title", children: [
|
|
1131
1223
|
d,
|
|
1132
|
-
|
|
1224
|
+
y && /* @__PURE__ */ s("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
|
|
1133
1225
|
] }),
|
|
1134
|
-
/* @__PURE__ */
|
|
1135
|
-
/* @__PURE__ */
|
|
1226
|
+
/* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
|
|
1227
|
+
/* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Card number" }),
|
|
1136
1228
|
/* @__PURE__ */ N("span", { className: "nice-credit-card__input-wrapper", children: [
|
|
1137
|
-
/* @__PURE__ */
|
|
1229
|
+
/* @__PURE__ */ s(
|
|
1138
1230
|
"input",
|
|
1139
1231
|
{
|
|
1140
|
-
id: `${
|
|
1232
|
+
id: `${E}-number`,
|
|
1141
1233
|
type: "text",
|
|
1142
1234
|
inputMode: "numeric",
|
|
1143
1235
|
autoComplete: "cc-number",
|
|
1144
|
-
placeholder:
|
|
1145
|
-
value:
|
|
1146
|
-
onChange:
|
|
1147
|
-
onBlur: () =>
|
|
1148
|
-
disabled:
|
|
1149
|
-
readOnly:
|
|
1150
|
-
"aria-invalid": !!
|
|
1151
|
-
"aria-describedby":
|
|
1236
|
+
placeholder: P === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
|
|
1237
|
+
value: M,
|
|
1238
|
+
onChange: oe,
|
|
1239
|
+
onBlur: () => z((w) => ({ ...w, number: !0 })),
|
|
1240
|
+
disabled: R,
|
|
1241
|
+
readOnly: q,
|
|
1242
|
+
"aria-invalid": !!T,
|
|
1243
|
+
"aria-describedby": T ? `${E}-number-err` : void 0,
|
|
1152
1244
|
className: "nice-credit-card__input",
|
|
1153
|
-
maxLength:
|
|
1245
|
+
maxLength: P === "amex" ? 17 : 23
|
|
1154
1246
|
}
|
|
1155
1247
|
),
|
|
1156
|
-
|
|
1248
|
+
i && /* @__PURE__ */ s(Mt, { brand: P })
|
|
1157
1249
|
] }),
|
|
1158
|
-
|
|
1250
|
+
T && /* @__PURE__ */ s("span", { id: `${E}-number-err`, className: "nice-credit-card__error", children: T })
|
|
1159
1251
|
] }) }),
|
|
1160
1252
|
/* @__PURE__ */ N("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
|
|
1161
1253
|
/* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1162
|
-
/* @__PURE__ */
|
|
1163
|
-
/* @__PURE__ */
|
|
1254
|
+
/* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Expiry" }),
|
|
1255
|
+
/* @__PURE__ */ s(
|
|
1164
1256
|
"input",
|
|
1165
1257
|
{
|
|
1166
|
-
id: `${
|
|
1258
|
+
id: `${E}-expiry`,
|
|
1167
1259
|
type: "text",
|
|
1168
1260
|
inputMode: "numeric",
|
|
1169
1261
|
autoComplete: "cc-exp",
|
|
1170
1262
|
placeholder: "MM/YY",
|
|
1171
1263
|
value: e.expiry,
|
|
1172
|
-
onChange:
|
|
1264
|
+
onChange: H,
|
|
1173
1265
|
onBlur: () => {
|
|
1174
|
-
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1266
|
+
z((I) => ({ ...I, expiry: !0 }));
|
|
1267
|
+
const w = Te(e.expiry);
|
|
1268
|
+
w && w !== e.expiry && A({ expiry: w });
|
|
1177
1269
|
},
|
|
1178
|
-
disabled:
|
|
1179
|
-
readOnly:
|
|
1180
|
-
"aria-invalid":
|
|
1181
|
-
"aria-describedby":
|
|
1270
|
+
disabled: R,
|
|
1271
|
+
readOnly: q,
|
|
1272
|
+
"aria-invalid": !!x,
|
|
1273
|
+
"aria-describedby": x ? `${E}-expiry-err` : void 0,
|
|
1182
1274
|
className: "nice-credit-card__input",
|
|
1183
1275
|
maxLength: 5
|
|
1184
1276
|
}
|
|
1185
1277
|
),
|
|
1186
|
-
|
|
1278
|
+
x && /* @__PURE__ */ s("span", { id: `${E}-expiry-err`, className: "nice-credit-card__error", children: x })
|
|
1187
1279
|
] }),
|
|
1188
1280
|
/* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1189
|
-
/* @__PURE__ */
|
|
1190
|
-
/* @__PURE__ */
|
|
1281
|
+
/* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: P === "amex" ? "CID" : "CVC" }),
|
|
1282
|
+
/* @__PURE__ */ s(
|
|
1191
1283
|
"input",
|
|
1192
1284
|
{
|
|
1193
|
-
id: `${
|
|
1285
|
+
id: `${E}-cvc`,
|
|
1194
1286
|
type: "text",
|
|
1195
1287
|
inputMode: "numeric",
|
|
1196
1288
|
autoComplete: "cc-csc",
|
|
1197
|
-
placeholder: "•".repeat(
|
|
1289
|
+
placeholder: "•".repeat(ye(P)),
|
|
1198
1290
|
value: e.cvc,
|
|
1199
|
-
onChange:
|
|
1200
|
-
onBlur: () =>
|
|
1201
|
-
disabled:
|
|
1202
|
-
readOnly:
|
|
1203
|
-
"aria-invalid": !!
|
|
1204
|
-
"aria-describedby":
|
|
1291
|
+
onChange: U,
|
|
1292
|
+
onBlur: () => z((w) => ({ ...w, cvc: !0 })),
|
|
1293
|
+
disabled: R,
|
|
1294
|
+
readOnly: q,
|
|
1295
|
+
"aria-invalid": !!le,
|
|
1296
|
+
"aria-describedby": le ? `${E}-cvc-err` : void 0,
|
|
1205
1297
|
className: "nice-credit-card__input",
|
|
1206
|
-
maxLength:
|
|
1298
|
+
maxLength: ye(P)
|
|
1207
1299
|
}
|
|
1208
1300
|
),
|
|
1209
|
-
|
|
1301
|
+
le && /* @__PURE__ */ s("span", { id: `${E}-cvc-err`, className: "nice-credit-card__error", children: le })
|
|
1210
1302
|
] })
|
|
1211
1303
|
] }),
|
|
1212
|
-
|
|
1213
|
-
/* @__PURE__ */
|
|
1214
|
-
/* @__PURE__ */
|
|
1304
|
+
c && /* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1305
|
+
/* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Cardholder name" }),
|
|
1306
|
+
/* @__PURE__ */ s(
|
|
1215
1307
|
"input",
|
|
1216
1308
|
{
|
|
1217
|
-
id: `${
|
|
1309
|
+
id: `${E}-holder`,
|
|
1218
1310
|
type: "text",
|
|
1219
1311
|
autoComplete: "cc-name",
|
|
1220
1312
|
placeholder: "Jane Doe",
|
|
1221
1313
|
value: e.holderName ?? "",
|
|
1222
|
-
onChange: (
|
|
1223
|
-
onBlur: () =>
|
|
1224
|
-
disabled:
|
|
1225
|
-
readOnly:
|
|
1314
|
+
onChange: (w) => A({ holderName: w.target.value }),
|
|
1315
|
+
onBlur: () => z((w) => ({ ...w, holder: !0 })),
|
|
1316
|
+
disabled: R,
|
|
1317
|
+
readOnly: q,
|
|
1226
1318
|
className: "nice-credit-card__input",
|
|
1227
1319
|
maxLength: 120
|
|
1228
1320
|
}
|
|
1229
1321
|
)
|
|
1230
1322
|
] }) }),
|
|
1231
|
-
a && /* @__PURE__ */
|
|
1232
|
-
/* @__PURE__ */
|
|
1233
|
-
/* @__PURE__ */
|
|
1323
|
+
a && /* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1324
|
+
/* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Postal code" }),
|
|
1325
|
+
/* @__PURE__ */ s(
|
|
1234
1326
|
"input",
|
|
1235
1327
|
{
|
|
1236
|
-
id: `${
|
|
1328
|
+
id: `${E}-postal`,
|
|
1237
1329
|
type: "text",
|
|
1238
1330
|
autoComplete: "postal-code",
|
|
1239
1331
|
value: e.postalCode ?? "",
|
|
1240
|
-
onChange: (
|
|
1241
|
-
onBlur: () =>
|
|
1242
|
-
disabled:
|
|
1243
|
-
readOnly:
|
|
1332
|
+
onChange: (w) => A({ postalCode: w.target.value }),
|
|
1333
|
+
onBlur: () => z((w) => ({ ...w, postal: !0 })),
|
|
1334
|
+
disabled: R,
|
|
1335
|
+
readOnly: q,
|
|
1244
1336
|
className: "nice-credit-card__input",
|
|
1245
1337
|
maxLength: 16
|
|
1246
1338
|
}
|
|
1247
1339
|
)
|
|
1248
1340
|
] }) }),
|
|
1249
|
-
(
|
|
1341
|
+
(h || f) && /* @__PURE__ */ s(
|
|
1250
1342
|
"div",
|
|
1251
1343
|
{
|
|
1252
|
-
className:
|
|
1253
|
-
role:
|
|
1254
|
-
children:
|
|
1344
|
+
className: h ? "nice-credit-card__form-error" : "nice-credit-card__helper",
|
|
1345
|
+
role: h ? "alert" : void 0,
|
|
1346
|
+
children: h ?? f
|
|
1255
1347
|
}
|
|
1256
1348
|
)
|
|
1257
1349
|
] });
|
|
1258
1350
|
}
|
|
1259
|
-
),
|
|
1351
|
+
), Ee = {
|
|
1260
1352
|
visa: "VISA",
|
|
1261
1353
|
mastercard: "MasterCard",
|
|
1262
1354
|
amex: "AMEX",
|
|
@@ -1270,305 +1362,406 @@ const De = te(function({
|
|
|
1270
1362
|
hipercard: "Hipercard",
|
|
1271
1363
|
unknown: ""
|
|
1272
1364
|
};
|
|
1273
|
-
function
|
|
1274
|
-
return
|
|
1365
|
+
function Mt({ brand: t }) {
|
|
1366
|
+
return t === "unknown" ? null : /* @__PURE__ */ s(
|
|
1275
1367
|
"span",
|
|
1276
1368
|
{
|
|
1277
|
-
className: `nice-credit-card__brand nice-credit-card__brand--${
|
|
1278
|
-
"aria-label":
|
|
1279
|
-
children:
|
|
1369
|
+
className: `nice-credit-card__brand nice-credit-card__brand--${t}`,
|
|
1370
|
+
"aria-label": Ee[t],
|
|
1371
|
+
children: Ee[t]
|
|
1280
1372
|
}
|
|
1281
1373
|
);
|
|
1282
1374
|
}
|
|
1283
|
-
const
|
|
1375
|
+
const Jt = de(
|
|
1284
1376
|
function({
|
|
1285
1377
|
processor: e,
|
|
1286
1378
|
amount: n,
|
|
1287
|
-
editableAmount:
|
|
1288
|
-
customer:
|
|
1379
|
+
editableAmount: c,
|
|
1380
|
+
customer: r,
|
|
1289
1381
|
currencies: a,
|
|
1290
1382
|
description: o,
|
|
1291
|
-
metadata:
|
|
1383
|
+
metadata: i,
|
|
1292
1384
|
autoCapture: l = !0,
|
|
1293
|
-
submitLabel:
|
|
1294
|
-
onSuccess:
|
|
1295
|
-
onError:
|
|
1296
|
-
consents:
|
|
1385
|
+
submitLabel: u = "Pay",
|
|
1386
|
+
onSuccess: m,
|
|
1387
|
+
onError: b,
|
|
1388
|
+
consents: p,
|
|
1297
1389
|
className: d,
|
|
1298
|
-
style:
|
|
1299
|
-
},
|
|
1300
|
-
const [
|
|
1301
|
-
var
|
|
1302
|
-
const
|
|
1303
|
-
return
|
|
1304
|
-
}, [e,
|
|
1305
|
-
var
|
|
1306
|
-
const
|
|
1307
|
-
return
|
|
1308
|
-
}, [e,
|
|
1309
|
-
async (
|
|
1310
|
-
if (
|
|
1311
|
-
|
|
1390
|
+
style: f
|
|
1391
|
+
}, h) {
|
|
1392
|
+
const [y, _] = B(n), [S, g] = B(n.currency), [v, O] = B({ number: "", expiry: "", cvc: "" }), [Y, Z] = B(null), [R, q] = B(!1), [ne, E] = B(null), J = St(e), z = k(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(y.currency.toUpperCase()), [e, y.currency]), P = k(() => {
|
|
1393
|
+
var M;
|
|
1394
|
+
const U = (M = e.minimums) == null ? void 0 : M[y.currency.toUpperCase()];
|
|
1395
|
+
return U == null || y.amount >= U;
|
|
1396
|
+
}, [e, y]), X = k(() => {
|
|
1397
|
+
var M;
|
|
1398
|
+
const U = (M = e.minimums) == null ? void 0 : M[y.currency.toUpperCase()];
|
|
1399
|
+
return U == null ? null : { amount: U, currency: y.currency };
|
|
1400
|
+
}, [e, y.currency]), se = !!(Y != null && Y.isValid), A = !R && z && P && se, oe = F(
|
|
1401
|
+
async (U) => {
|
|
1402
|
+
if (U.preventDefault(), !!A) {
|
|
1403
|
+
E(null), q(!0);
|
|
1312
1404
|
try {
|
|
1313
|
-
const
|
|
1314
|
-
amount:
|
|
1315
|
-
card:
|
|
1316
|
-
customer:
|
|
1405
|
+
const M = {
|
|
1406
|
+
amount: y,
|
|
1407
|
+
card: v,
|
|
1408
|
+
customer: r,
|
|
1317
1409
|
description: o,
|
|
1318
|
-
metadata:
|
|
1319
|
-
idempotencyKey:
|
|
1320
|
-
},
|
|
1321
|
-
if (l &&
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1410
|
+
metadata: i,
|
|
1411
|
+
idempotencyKey: Pt()
|
|
1412
|
+
}, T = await J.authorize(M);
|
|
1413
|
+
if (l && T.status === "authorized") {
|
|
1414
|
+
const x = await J.capture(T.id, y);
|
|
1415
|
+
m == null || m(x);
|
|
1324
1416
|
} else
|
|
1325
|
-
|
|
1326
|
-
} catch (
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1417
|
+
m == null || m(T);
|
|
1418
|
+
} catch (M) {
|
|
1419
|
+
const T = M instanceof Error ? M : new Error(String(M));
|
|
1420
|
+
E(T.message), b == null || b(T);
|
|
1329
1421
|
} finally {
|
|
1330
|
-
|
|
1422
|
+
q(!1);
|
|
1331
1423
|
}
|
|
1332
1424
|
}
|
|
1333
1425
|
},
|
|
1334
1426
|
[
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1427
|
+
A,
|
|
1428
|
+
y,
|
|
1429
|
+
v,
|
|
1430
|
+
r,
|
|
1339
1431
|
o,
|
|
1340
|
-
|
|
1432
|
+
i,
|
|
1341
1433
|
l,
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1434
|
+
J,
|
|
1435
|
+
m,
|
|
1436
|
+
b
|
|
1345
1437
|
]
|
|
1346
|
-
),
|
|
1438
|
+
), H = V(y.currency);
|
|
1347
1439
|
return /* @__PURE__ */ N(
|
|
1348
1440
|
"form",
|
|
1349
1441
|
{
|
|
1350
|
-
ref:
|
|
1442
|
+
ref: h,
|
|
1351
1443
|
className: "nice-payment-form" + (d ? ` ${d}` : ""),
|
|
1352
|
-
style:
|
|
1353
|
-
onSubmit:
|
|
1354
|
-
"aria-busy":
|
|
1444
|
+
style: f,
|
|
1445
|
+
onSubmit: oe,
|
|
1446
|
+
"aria-busy": R,
|
|
1355
1447
|
children: [
|
|
1356
|
-
/* @__PURE__ */
|
|
1357
|
-
|
|
1448
|
+
/* @__PURE__ */ s("div", { className: "nice-payment-form__amount", children: c ? /* @__PURE__ */ s(
|
|
1449
|
+
He,
|
|
1358
1450
|
{
|
|
1359
1451
|
label: "Amount",
|
|
1360
|
-
value:
|
|
1361
|
-
currency:
|
|
1452
|
+
value: y,
|
|
1453
|
+
currency: S,
|
|
1362
1454
|
currencies: a,
|
|
1363
|
-
onChange: (
|
|
1364
|
-
onCurrencyChange: (
|
|
1365
|
-
|
|
1455
|
+
onChange: (U) => U && _(U),
|
|
1456
|
+
onCurrencyChange: (U) => {
|
|
1457
|
+
g(U), _((M) => ({ ...M, currency: U }));
|
|
1366
1458
|
},
|
|
1367
|
-
disabled:
|
|
1459
|
+
disabled: R,
|
|
1368
1460
|
required: !0,
|
|
1369
1461
|
showFormattedPreview: !0
|
|
1370
1462
|
}
|
|
1371
1463
|
) : /* @__PURE__ */ N("div", { className: "nice-payment-form__total", children: [
|
|
1372
|
-
/* @__PURE__ */
|
|
1373
|
-
/* @__PURE__ */
|
|
1464
|
+
/* @__PURE__ */ s("span", { className: "nice-payment-form__total-label", children: "Total" }),
|
|
1465
|
+
/* @__PURE__ */ s(Fe, { value: y })
|
|
1374
1466
|
] }) }),
|
|
1375
|
-
o && /* @__PURE__ */
|
|
1376
|
-
/* @__PURE__ */
|
|
1377
|
-
|
|
1467
|
+
o && /* @__PURE__ */ s("p", { className: "nice-payment-form__description", children: o }),
|
|
1468
|
+
/* @__PURE__ */ s("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ s(
|
|
1469
|
+
Rt,
|
|
1378
1470
|
{
|
|
1379
|
-
value:
|
|
1380
|
-
onChange: (
|
|
1381
|
-
|
|
1471
|
+
value: v,
|
|
1472
|
+
onChange: (U, M) => {
|
|
1473
|
+
O(U), Z(M);
|
|
1382
1474
|
},
|
|
1383
|
-
disabled:
|
|
1475
|
+
disabled: R
|
|
1384
1476
|
}
|
|
1385
1477
|
) }),
|
|
1386
|
-
!
|
|
1478
|
+
!z && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1387
1479
|
e.name,
|
|
1388
1480
|
" does not accept ",
|
|
1389
|
-
(
|
|
1481
|
+
(H == null ? void 0 : H.name) ?? y.currency,
|
|
1390
1482
|
"."
|
|
1391
1483
|
] }),
|
|
1392
|
-
!
|
|
1484
|
+
!P && X && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1393
1485
|
"Minimum charge for ",
|
|
1394
1486
|
e.name,
|
|
1395
1487
|
" is ",
|
|
1396
|
-
/* @__PURE__ */
|
|
1488
|
+
/* @__PURE__ */ s(Fe, { value: X }),
|
|
1397
1489
|
"."
|
|
1398
1490
|
] }),
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
/* @__PURE__ */
|
|
1491
|
+
p && /* @__PURE__ */ s("div", { className: "nice-payment-form__consents", children: p }),
|
|
1492
|
+
ne && /* @__PURE__ */ s("div", { className: "nice-payment-form__error", role: "alert", children: ne }),
|
|
1493
|
+
/* @__PURE__ */ s(
|
|
1402
1494
|
"button",
|
|
1403
1495
|
{
|
|
1404
1496
|
type: "submit",
|
|
1405
1497
|
className: "nice-payment-form__submit",
|
|
1406
|
-
disabled: !
|
|
1407
|
-
"aria-disabled": !
|
|
1408
|
-
children:
|
|
1498
|
+
disabled: !A,
|
|
1499
|
+
"aria-disabled": !A,
|
|
1500
|
+
children: R ? "Processing…" : u
|
|
1409
1501
|
}
|
|
1410
1502
|
),
|
|
1411
1503
|
/* @__PURE__ */ N("p", { className: "nice-payment-form__processor", children: [
|
|
1412
1504
|
"Secured by ",
|
|
1413
|
-
/* @__PURE__ */
|
|
1505
|
+
/* @__PURE__ */ s("strong", { children: e.name })
|
|
1414
1506
|
] })
|
|
1415
1507
|
]
|
|
1416
1508
|
}
|
|
1417
1509
|
);
|
|
1418
1510
|
}
|
|
1419
1511
|
);
|
|
1420
|
-
function
|
|
1512
|
+
function Pt() {
|
|
1421
1513
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
|
|
1422
1514
|
}
|
|
1423
|
-
const
|
|
1515
|
+
const Xt = de(function({
|
|
1424
1516
|
price: e,
|
|
1425
1517
|
originalPrice: n,
|
|
1426
|
-
period:
|
|
1427
|
-
prefix:
|
|
1518
|
+
period: c,
|
|
1519
|
+
prefix: r,
|
|
1428
1520
|
suffix: a,
|
|
1429
1521
|
showDiscountBadge: o = !0,
|
|
1430
|
-
size:
|
|
1522
|
+
size: i = "md",
|
|
1431
1523
|
locale: l,
|
|
1432
|
-
className:
|
|
1433
|
-
style:
|
|
1434
|
-
},
|
|
1435
|
-
const
|
|
1436
|
-
return /* @__PURE__ */ N("div", { ref:
|
|
1437
|
-
|
|
1524
|
+
className: u,
|
|
1525
|
+
style: m
|
|
1526
|
+
}, b) {
|
|
1527
|
+
const p = n && n.currency === e.currency && n.amount > e.amount, d = k(() => !p || !n ? null : Math.round((n.amount - e.amount) / n.amount * 100), [p, n, e.amount]), f = `nice-price-tag nice-price-tag--${i}` + (u ? ` ${u}` : "");
|
|
1528
|
+
return /* @__PURE__ */ N("div", { ref: b, className: f, style: m, children: [
|
|
1529
|
+
r && /* @__PURE__ */ s("span", { className: "nice-price-tag__prefix", children: r }),
|
|
1438
1530
|
/* @__PURE__ */ N("span", { className: "nice-price-tag__main", children: [
|
|
1439
|
-
/* @__PURE__ */
|
|
1440
|
-
|
|
1531
|
+
/* @__PURE__ */ s("span", { className: "nice-price-tag__amount", children: te(e, { locale: l }) }),
|
|
1532
|
+
c && /* @__PURE__ */ s("span", { className: "nice-price-tag__period", children: c })
|
|
1441
1533
|
] }),
|
|
1442
|
-
|
|
1443
|
-
|
|
1534
|
+
p && n && /* @__PURE__ */ s("span", { className: "nice-price-tag__original", "aria-label": "Original price", children: /* @__PURE__ */ s("s", { children: te(n, { locale: l }) }) }),
|
|
1535
|
+
p && o && d != null && d > 0 && /* @__PURE__ */ N("span", { className: "nice-price-tag__discount", "aria-label": `${d} percent off`, children: [
|
|
1444
1536
|
"−",
|
|
1445
1537
|
d,
|
|
1446
1538
|
"%"
|
|
1447
1539
|
] }),
|
|
1448
|
-
a && /* @__PURE__ */
|
|
1540
|
+
a && /* @__PURE__ */ s("span", { className: "nice-price-tag__suffix", children: a })
|
|
1449
1541
|
] });
|
|
1450
|
-
}),
|
|
1542
|
+
}), Qt = de(
|
|
1451
1543
|
function({
|
|
1452
1544
|
source: e,
|
|
1453
1545
|
onSourceChange: n,
|
|
1454
|
-
targetCurrency:
|
|
1455
|
-
onTargetCurrencyChange:
|
|
1546
|
+
targetCurrency: c,
|
|
1547
|
+
onTargetCurrencyChange: r,
|
|
1456
1548
|
provider: a,
|
|
1457
1549
|
locale: o,
|
|
1458
|
-
showRateLine:
|
|
1550
|
+
showRateLine: i = !0,
|
|
1459
1551
|
className: l,
|
|
1460
|
-
style:
|
|
1461
|
-
},
|
|
1462
|
-
const { converted:
|
|
1552
|
+
style: u
|
|
1553
|
+
}, m) {
|
|
1554
|
+
const { converted: b, loading: p, error: d } = ve(e, c, a), f = k(
|
|
1463
1555
|
() => ({ amount: Math.pow(10, 2), currency: e.currency }),
|
|
1464
1556
|
[e.currency]
|
|
1465
|
-
), { converted:
|
|
1466
|
-
|
|
1467
|
-
|
|
1557
|
+
), { converted: h } = ve(
|
|
1558
|
+
i ? f : null,
|
|
1559
|
+
c,
|
|
1468
1560
|
a
|
|
1469
1561
|
);
|
|
1470
1562
|
return /* @__PURE__ */ N(
|
|
1471
1563
|
"div",
|
|
1472
1564
|
{
|
|
1473
|
-
ref:
|
|
1565
|
+
ref: m,
|
|
1474
1566
|
className: "nice-currency-converter" + (l ? ` ${l}` : ""),
|
|
1475
|
-
style:
|
|
1567
|
+
style: u,
|
|
1476
1568
|
children: [
|
|
1477
|
-
/* @__PURE__ */
|
|
1478
|
-
|
|
1569
|
+
/* @__PURE__ */ s("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ s(
|
|
1570
|
+
He,
|
|
1479
1571
|
{
|
|
1480
1572
|
label: "From",
|
|
1481
1573
|
value: e,
|
|
1482
|
-
onChange: (
|
|
1574
|
+
onChange: (y) => y && n(y),
|
|
1483
1575
|
currency: e.currency,
|
|
1484
|
-
onCurrencyChange: (
|
|
1576
|
+
onCurrencyChange: (y) => n({ ...e, currency: y }),
|
|
1485
1577
|
showFormattedPreview: !1
|
|
1486
1578
|
}
|
|
1487
1579
|
) }),
|
|
1488
1580
|
/* @__PURE__ */ N("div", { className: "nice-currency-converter__row", children: [
|
|
1489
|
-
/* @__PURE__ */
|
|
1581
|
+
/* @__PURE__ */ s("label", { className: "nice-currency-converter__label", children: "To" }),
|
|
1490
1582
|
/* @__PURE__ */ N("div", { className: "nice-currency-converter__output", children: [
|
|
1491
|
-
/* @__PURE__ */
|
|
1492
|
-
|
|
1583
|
+
/* @__PURE__ */ s(
|
|
1584
|
+
qe,
|
|
1493
1585
|
{
|
|
1494
|
-
value:
|
|
1495
|
-
onChange: (
|
|
1586
|
+
value: c,
|
|
1587
|
+
onChange: (y) => r(y),
|
|
1496
1588
|
compact: !0
|
|
1497
1589
|
}
|
|
1498
1590
|
),
|
|
1499
|
-
/* @__PURE__ */
|
|
1591
|
+
/* @__PURE__ */ s("span", { className: "nice-currency-converter__amount", children: p ? "…" : d ? "—" : b ? te(b, { locale: o }) : "" })
|
|
1500
1592
|
] })
|
|
1501
1593
|
] }),
|
|
1502
|
-
|
|
1594
|
+
i && h && /* @__PURE__ */ N("p", { className: "nice-currency-converter__rate", children: [
|
|
1503
1595
|
"1 ",
|
|
1504
1596
|
e.currency,
|
|
1505
1597
|
" = ",
|
|
1506
|
-
|
|
1598
|
+
te(h, { locale: o }),
|
|
1507
1599
|
" ",
|
|
1508
1600
|
/* @__PURE__ */ N("span", { className: "nice-currency-converter__inverse", children: [
|
|
1509
1601
|
"· 1 ",
|
|
1510
|
-
|
|
1602
|
+
c,
|
|
1511
1603
|
" =",
|
|
1512
1604
|
" ",
|
|
1513
|
-
|
|
1605
|
+
te(W(1 / Ke(h), e.currency), { locale: o })
|
|
1514
1606
|
] })
|
|
1515
1607
|
] }),
|
|
1516
|
-
d && /* @__PURE__ */
|
|
1608
|
+
d && /* @__PURE__ */ s("p", { className: "nice-currency-converter__error", role: "alert", children: d.message })
|
|
1609
|
+
]
|
|
1610
|
+
}
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
);
|
|
1614
|
+
function Ae(t) {
|
|
1615
|
+
return { amount: Math.round(t.amount), currency: t.currency };
|
|
1616
|
+
}
|
|
1617
|
+
const Vt = de(
|
|
1618
|
+
function({
|
|
1619
|
+
lines: e,
|
|
1620
|
+
locale: n,
|
|
1621
|
+
rounding: c = "line",
|
|
1622
|
+
showTotals: r = !0,
|
|
1623
|
+
showGrandTotal: a = !0,
|
|
1624
|
+
hideRateColumn: o = !1,
|
|
1625
|
+
labels: i,
|
|
1626
|
+
density: l = "comfortable",
|
|
1627
|
+
className: u,
|
|
1628
|
+
style: m,
|
|
1629
|
+
id: b
|
|
1630
|
+
}, p) {
|
|
1631
|
+
const d = {
|
|
1632
|
+
label: (i == null ? void 0 : i.label) ?? "Item",
|
|
1633
|
+
rate: (i == null ? void 0 : i.rate) ?? "VAT",
|
|
1634
|
+
net: (i == null ? void 0 : i.net) ?? "Net",
|
|
1635
|
+
vat: (i == null ? void 0 : i.vat) ?? "Tax",
|
|
1636
|
+
gross: (i == null ? void 0 : i.gross) ?? "Gross",
|
|
1637
|
+
total: (i == null ? void 0 : i.total) ?? "Total"
|
|
1638
|
+
}, f = k(() => {
|
|
1639
|
+
if (c === "total") {
|
|
1640
|
+
const _ = /* @__PURE__ */ new Map();
|
|
1641
|
+
for (const g of e) {
|
|
1642
|
+
let v = _.get(g.vatRate);
|
|
1643
|
+
v || (v = [], _.set(g.vatRate, v)), v.push(g.netAmount);
|
|
1644
|
+
}
|
|
1645
|
+
const S = [];
|
|
1646
|
+
for (const [g, v] of _) {
|
|
1647
|
+
const O = v.reduce((R, q) => me(R, q), W(0, v[0].currency)), Y = Ae(De(O, g)), Z = me(O, Y);
|
|
1648
|
+
S.push({ rate: g, net: O, vat: Y, gross: Z });
|
|
1649
|
+
}
|
|
1650
|
+
return S;
|
|
1651
|
+
}
|
|
1652
|
+
return e.map((_) => {
|
|
1653
|
+
const S = Ae(De(_.netAmount, _.vatRate)), g = me(_.netAmount, S);
|
|
1654
|
+
return { label: _.label, rate: _.vatRate, net: _.netAmount, vat: S, gross: g };
|
|
1655
|
+
});
|
|
1656
|
+
}, [e, c]), h = k(() => {
|
|
1657
|
+
if (f.length === 0)
|
|
1658
|
+
return null;
|
|
1659
|
+
const _ = f[0].net.currency;
|
|
1660
|
+
let S = W(0, _), g = W(0, _), v = W(0, _);
|
|
1661
|
+
for (const O of f)
|
|
1662
|
+
S = me(S, O.net), g = me(g, O.vat), v = me(v, O.gross);
|
|
1663
|
+
return { net: S, vat: g, gross: v };
|
|
1664
|
+
}, [f]), y = (_) => te(_, { locale: n });
|
|
1665
|
+
return /* @__PURE__ */ N(
|
|
1666
|
+
"table",
|
|
1667
|
+
{
|
|
1668
|
+
ref: p,
|
|
1669
|
+
id: b,
|
|
1670
|
+
className: `nice-tax-breakdown nice-tax-breakdown--${l} ${u ?? ""}`,
|
|
1671
|
+
style: m,
|
|
1672
|
+
role: "table",
|
|
1673
|
+
"aria-label": d.total,
|
|
1674
|
+
children: [
|
|
1675
|
+
/* @__PURE__ */ s("thead", { children: /* @__PURE__ */ N("tr", { children: [
|
|
1676
|
+
f.some((_) => _.label !== void 0) && /* @__PURE__ */ s("th", { scope: "col", children: d.label }),
|
|
1677
|
+
!o && /* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__rate", children: d.rate }),
|
|
1678
|
+
/* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.net }),
|
|
1679
|
+
/* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.vat }),
|
|
1680
|
+
/* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.gross })
|
|
1681
|
+
] }) }),
|
|
1682
|
+
/* @__PURE__ */ s("tbody", { children: f.map((_, S) => /* @__PURE__ */ N("tr", { children: [
|
|
1683
|
+
f.some((g) => g.label !== void 0) && /* @__PURE__ */ s("td", { children: _.label ?? "" }),
|
|
1684
|
+
!o && /* @__PURE__ */ N("td", { className: "nice-tax-breakdown__rate", children: [
|
|
1685
|
+
(_.rate * 100).toLocaleString(n, { maximumFractionDigits: 2 }),
|
|
1686
|
+
"%"
|
|
1687
|
+
] }),
|
|
1688
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.net) }),
|
|
1689
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.vat) }),
|
|
1690
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.gross) })
|
|
1691
|
+
] }, `${_.rate}-${S}`)) }),
|
|
1692
|
+
r && h && /* @__PURE__ */ s("tfoot", { children: a && /* @__PURE__ */ N("tr", { className: "nice-tax-breakdown__totals", children: [
|
|
1693
|
+
f.some((_) => _.label !== void 0) && /* @__PURE__ */ s("td", { children: d.total }),
|
|
1694
|
+
!o && /* @__PURE__ */ s("td", {}),
|
|
1695
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.net) }),
|
|
1696
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.vat) }),
|
|
1697
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.gross) })
|
|
1698
|
+
] }) })
|
|
1517
1699
|
]
|
|
1518
1700
|
}
|
|
1519
1701
|
);
|
|
1520
1702
|
}
|
|
1521
1703
|
);
|
|
1522
1704
|
export {
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1705
|
+
lt as EcbRatesProvider,
|
|
1706
|
+
st as ExchangeRateHostProvider,
|
|
1707
|
+
at as FrankfurterProvider,
|
|
1708
|
+
ut as FreeForexApiProvider,
|
|
1709
|
+
mt as MockPaymentProcessor,
|
|
1710
|
+
fe as NICE_CURRENCY_CATALOG,
|
|
1711
|
+
Zt as NICE_CURRENCY_CODES,
|
|
1712
|
+
Gt as NICE_PAYMENT_PROCESSORS,
|
|
1713
|
+
ot as NbpRatesProvider,
|
|
1714
|
+
Rt as NiceCreditCardInput,
|
|
1715
|
+
Qt as NiceCurrencyConverter,
|
|
1716
|
+
qe as NiceCurrencySelector,
|
|
1717
|
+
Fe as NiceMoney,
|
|
1718
|
+
He as NiceMoneyInput,
|
|
1719
|
+
Jt as NicePaymentForm,
|
|
1720
|
+
Xt as NicePriceTag,
|
|
1721
|
+
Vt as NiceTaxBreakdown,
|
|
1722
|
+
it as OpenExchangeRatesProvider,
|
|
1723
|
+
Lt as StaticExchangeRateProvider,
|
|
1724
|
+
me as addMoney,
|
|
1725
|
+
At as compareMoney,
|
|
1726
|
+
dt as convertMoney,
|
|
1727
|
+
Ht as createEcbRatesProvider,
|
|
1728
|
+
zt as createFreeForexApiProvider,
|
|
1729
|
+
qt as createNbpRatesProvider,
|
|
1730
|
+
jt as createOpenExchangeRatesProvider,
|
|
1731
|
+
Ne as detectCardBrand,
|
|
1732
|
+
ye as expectedCvcLength,
|
|
1733
|
+
V as findCurrency,
|
|
1734
|
+
ct as formatCardNumber,
|
|
1735
|
+
te as formatMoney,
|
|
1736
|
+
Ke as fromMoney,
|
|
1737
|
+
Le as isExpiryValid,
|
|
1738
|
+
Kt as isNegative,
|
|
1739
|
+
Ot as isZero,
|
|
1740
|
+
Be as luhnCheck,
|
|
1741
|
+
ft as makeAdyenAdapter,
|
|
1742
|
+
vt as makeAutopayAdapter,
|
|
1743
|
+
Ct as makeBlikAdapter,
|
|
1744
|
+
_t as makeBraintreeAdapter,
|
|
1745
|
+
xt as makeCoinbaseCommerceAdapter,
|
|
1746
|
+
$t as makeKlarnaAdapter,
|
|
1747
|
+
bt as makeMollieAdapter,
|
|
1748
|
+
yt as makePayPalAdapter,
|
|
1749
|
+
gt as makePayUAdapter,
|
|
1750
|
+
wt as makePrzelewy24Adapter,
|
|
1751
|
+
Nt as makeRazorpayAdapter,
|
|
1752
|
+
ht as makeSquareAdapter,
|
|
1753
|
+
pt as makeStripeAdapter,
|
|
1754
|
+
Dt as makeTpayAdapter,
|
|
1755
|
+
Tt as maskCardNumber,
|
|
1756
|
+
De as multiplyMoney,
|
|
1757
|
+
Bt as negateMoney,
|
|
1758
|
+
Te as normaliseExpiry,
|
|
1759
|
+
rt as parseMoney,
|
|
1760
|
+
Et as registerCurrency,
|
|
1761
|
+
nt as subtractMoney,
|
|
1762
|
+
W as toMoney,
|
|
1763
|
+
ve as useNiceExchangeRate,
|
|
1764
|
+
Yt as useNiceMoney,
|
|
1765
|
+
St as useNicePayment,
|
|
1766
|
+
Ie as validateCreditCard
|
|
1574
1767
|
};
|